Salesforce Agentforce Apex Agent Action
4K views
Nov 11, 2024
@InvocableMethod annotation helps to invoke apex class and method from the Salesforce Agentforce Apex Action. @InvocableVariable annotation can be used to pass multiple parameters from the Salesforce Agent Action to the Apex Class. Blog Post: https://www.infallibletechie.com/2024/11/salesforce-agentforce-apex-agent-action.html
View Video Transcript
0:06
hello everyone in this video we are
0:08
going to see how to invoke Apex
0:15
actions for Salesforce agent
0:18
force I have created a simple Apex class
0:23
here in order
0:25
to call the Apex method
0:30
I am using a rapper class with two
0:34
variables object name and field name
0:38
since I'm using at invocable
0:42
variable I will be able
0:44
to pass the parameter value for object
0:47
name and field name whenever I'm
0:50
configuring agent
0:54
action I'm using at invocable method
0:57
annotation so that this particular
1:00
method will be
1:03
exposed when configuring agent action to
1:07
invoke this Apex
1:10
class from
1:12
the input I'm get getting the object
1:15
name and field name and
1:18
using schema. get Global describe I'm
1:22
getting the object
1:25
descriptions and from there I'm I'm I'm
1:28
getting the value value of s object
1:31
typee only for the object name that was
1:34
passed and
1:36
using S object uh field I'm getting all
1:40
the
1:41
fields using schema. S object field I'm
1:44
getting all the map of fields but I want
1:47
to know only one specific field so I'm
1:50
so whatever field name is passed it will
1:53
be uh uh passed to this map and then we
1:56
will get Only One S object
1:58
field next using schema. picklist entry
2:03
I'm getting the pick list values for
2:06
that particular
2:08
field and I'm iterating each and every
2:10
uh pick list
2:13
entry and then I'm adding it to a list
2:17
of string
2:18
variable and finally I'm adding it to
2:20
list of
2:21
list so that I can return it uh as a
2:25
list of string to the agent action so
2:27
this is my sample Apex class let's see
2:30
the agent action here so I'm using two
2:34
agent action one to fetch a product City
2:37
pick list value in product object I
2:40
created a City
2:41
Field uh so it is a custom field so I
2:45
will get all the pick list values for
2:47
that so this is the configuration I have
2:50
done for that so this is the agent
2:53
action
2:54
instruction these two
2:56
are input fields
3:02
I made it as required whenever it is
3:05
invoking it and then it will display the
3:09
list of cities uh for the customer to
3:13
select output rendering type is
3:16
list I am also making use of the
3:20
instructions to be
3:25
passed next same Apex I'm using using a
3:30
different agent action called Fetch
3:32
product family big list values so in
3:35
product object we have family product
3:38
family as a standard field the API name
3:41
is family so I am going to Fitch the
3:45
different uh pick list values that are
3:48
available in the product
3:50
family let's see a demo so I'm going to
3:54
invoke my
3:56
uh messaging for inapp and web it will
3:59
uh invoke my agent force I will say I
4:03
would like
4:05
to go on
4:09
order it will ask my email
4:16
ID it is asking my email ID to verify so
4:19
let me enter my email
4:23
address this is a sample dummy email
4:27
which I have it in my or so it is
4:30
showing digital and
4:32
static by invoking this uh particular
4:37
agent action so this is calling the Apex
4:40
it is displaying
4:42
the list
4:45
of product
4:53
families now it is displaying the
4:55
available
4:58
cities by in working that Apex class
5:02
let's go to the product object and I
5:04
will show
5:14
the so in the product family I have two
5:17
values digital and
5:19
static and here for the
5:22
city I have entered five cities so it
5:26
was able to display those five cities
5:33
please check the video description in
5:35
the video description I have shared my
5:37
blog post from the blog post you should
5:39
be able to get the sample code for your
5:50
reference I hope it was
5:58
helpful thank you for watching
#Internet Software