top of page
OmniStudioFactBg.png
Writer's pictureSagar Shanbogh

How to use a Lookup Element in OmniScript

Lookup elements display values from Salesforce based on a standard SOQL query built using the parameters of the Lookup elements.

The retrieved data is returned in Value/Label pairs and becomes available for selection in a dropdown list.


Let’s see how to configure a Lookup Element in an OmniScript by using different data source type.


First, create a new OmniScript with appropriate Type/Subtype & Description.

Second, add a Lookup Element from the Build panel inside the inputs section.


We can define the Data Source Type as SObject, Custom or Picklist Filtered By Record Type for the Lookup element to execute as per the requirement.



Data Source Type as SObject


Let us consider an example here to get the list of Contacts that are related to Account.


1) Once you select Data Source Type as SObject , the Input Parameters will be asked.

2) Data Source: Once we start typing any value in the Data Source Key field, it will display all the element names already present in the particular step of the Omniscript. We can choose those elements based on our requirement. For our example, we are trying to fetch the contacts related to an account Id, so let us provide the Data Source value as “ContextId” (assuming that we will be providing an Account sfdc Id as ContextId)


3) Filter Value: Enter a name for the JSON value to use in the lookup query configuration that we are going to do as next configuration. For our example, let us provide the Filter Value as “Id”.

4) After adding the Input Parameters, we need to Configure the Lookup Query Configuration. At Least there should be a one lookup query configuration so based on that it will show the results.

  • Click + Add New Lookup Query Configuration.

  • In Lookup Order, enter a number to set priority for the Lookup order, if we are using multiple queries so we need to keep increasing the Lookup order field.

  • In Lookup Object, select an SObject. Let's choose “Contact”, because we are trying to fetch the contacts.

  • In Lookup Object Field, select an SObject field to run the query against. Let’s choose AccountId.

  • Click Filter Operator to select an operator. For example, to return an exact match, use the = operator (or to select matches similar to the filter value, select the LIKE operator).

  • In Filter Value, enter the name of the “Filter Value” used in the Input Parameters section(Id).

  • In JSON Path enter any value through this we are going to access the result. Lets keep the value as “Contact”, which will be used in our next configuration.

  • Click Save.


Note: If You want to add/execute multiple queries based on some different fields of the different object/same object,Click + Lookup Query Configuration and make sure that you need to change the Lookup Order to ‘2’.



5) As the next step, in the Populate Lookup Element with Query Results section, set a label and a value for the Lookup results.

  • JSON Path Use As The Value in Lookup: The mapping that we do here will be used to form the JSON in OS, when a lookup value is selected. Ex: To form Contact Id as JSON value when a user selects an Contact Name from the Lookup element, the full path is Contact:Id.

  • JSON Path Use As The Label in Lookup: The mapping that we do here will be used to display the label in the lookup element. Ex: To display Contact Name as a label in a Lookup Element named Contact, the full path is Contact:Name.

6) Finally, activate the OmniScripts to test the functionality. You can notice based on the ContextId (As per the assumption, an Account Id will be passed to Omniscript and used as ContextId), the related contacts are fetched and displayed.


Data Source Type as Picklist Filtered by RecordType


1) Select Data Source Type as Picklist Filtered by RecordType on the lookup element.



2) In Picklist Object and Field, enter the object name and the field name (ObjectAPIName.FieldAPIName). Ex: Account.AccountSource.


3) In the Record Type field, enter the record type name that you want to filter the picklist.


Output: You can notice that only the picklist values available under the record type mentioned will be fetched and displayed in the lookup field.



4) If we want to display all the picklists related to that field we can use Master.


Output: You can notice all the picklist values related to that field will be fetched and displayed in the lookup field.


Note : Record Type field is mandatory(required), so we must populate it with any record type value.

References:











1,453 views0 comments

Recent Posts

See All

Comments


bottom of page