---
schema_version: "1"
id: 1754eaa2ec52f0dcfcaedaf010655cb363381523ab751174671269182a895081
title: Query Salesforce Data from an Omniscipt with the Lookup Element
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_lookup_element_21681.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_lookup_element_21681.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 64c574652bd9f176d42f35d3893b9bcfa8d42fd1905b218aa48b6597e13b4a5a
description: Run a query using text input to retrieve Salesforce data using the Lookup element. The retrieved data is returned in value-label pairs and becomes available for selection in a dropdown list.
products:
  - Omnistudio
release: "264"
---
# Query Salesforce Data from an Omniscipt with the Lookup Element

Run a query using text input to retrieve Salesforce data using the Lookup element. The retrieved data is returned in value-label pairs and becomes available for selection in a dropdown list.

The Lookup element calls the Omnistudio Data Mapper Extract service to query sObject tables based on the parameters configured in the Properties section. To avoid performance issues, keeping the number of value results under 150 is recommended. To use a custom Apex class to perform the lookup, select the Custom type. Lookup elements display values from Salesforce based on a standard SOQL query built using the parameters of the Lookup elements.

## SObject Type

To query for SObject data:

1. Set the Data Source Type to **SObject**.
2. Under **Input Parameters**, configure these fields:
    - **Data Source**: Select an Element Name from the dropdown to send that element's JSON value in the lookup request. For example, suppose the Data Source is a Text input element named CompanyName that asks the user for the name of an Account.
    - **Filter Value**: Enter a name for the JSON value to use in the lookup query. You can use any value as long as it matches a Filter Value in a Lookup Query Configuration.
3. Configure the Lookup Query Configuration:
    1. Click **Add New Lookup Query Configuration**.
    2. Enter a number to set priority for the Lookup order if there are multiple queries.
    3. Select a Lookup SObject.
        
        For example, Account.
    4. Select a Lookup SObject Field field to run the query on.
        
        For example, Name.
    5. 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.
    6. Enter the name of a Filter Value used in the Input Parameters section.
        
        For example, Company Name.
    7. Set the return path for the filtered values by adding the element name of the Lookup element in the **JSON path**.
        
        For example, Company.
4. In the Populate Lookup Element with Query Results section, set a label and a value for the Lookup results by configuring these fields:
    - Label: Set the label for a Lookup Element's dropdown list to a JSON Value returned by the query. Because the query returns the values in the Lookup Element's JSON Path, you must set the full path. For example, to display an Account Name as a label in a Lookup Element named Company, the full path is Company:Name.
    - Value: Set the Value to an Object field that populates the Lookup Element's JSON Node using the full path. When a user selects a label, the value populates the Lookup element's JSON Node. For example, to use an Account Id for a JSON value when a user selects an Account Name from the Lookup element, the full path is Company:Id.
5. Preview the Omniscript to ensure the query is working and the value is being set correctly.
    
    The query is structured in this format:
    
    `SELECT Lookup Object WHERE Lookup Object.Field Name = Filter Value`

## Custom Type

Use the Custom type to call a custom Apex class.

The Apex class implements Callable or namespace.VlocityOpenInterface, where namespace is the namespace of the package. The source is namespace.ClassName.MethodName.

For more details on query configurations, see Working with [Working with Lookup Query Configurations](https://help.salesforce.com/s/articleView?id=xcloud.os_lookup_element_21681.htm&release=264.0.0&type=5 "When using the Lookup Element in Omniscript, the filtering of results is performed by the Lookup Query Configuration properties section. There are three main types of queries that can be built using this the Lookup Query Configuration properties section: AND join, OR join, and Deep query.").

## Picklist Filter by Record Type

Enable the filtering of picklist options by record type.

You can look up picklist fields and record types for an object in Setup in the Object Manager.

1. In the **Picklist Object and Field** property, enter the picklist in this format: ObjectAPIName.FieldAPIName.
2. Filter the picklist by **Record Type**.

## Working with Lookup Query Configurations

When using the Lookup Element in Omniscript, the filtering of results is performed by the Lookup Query Configuration properties section. There are three main types of queries that can be built using this the Lookup Query Configuration properties section: AND join, OR join, and Deep query.

**AND Join**

To create AND Join and filter results on two or more fields set the sequence field value to the same value as the fields you want to join together in the query.

**Example AND Join**

![image](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio-264-0-0-production-enus/f526eaa8-ae05-487a-8944-4bb99b0b78ac/omnistudio/images/salesforce_omniscript_andjoin.png)

In this example, we search for Leads that have Country = "USA" AND City = "San Francisco". This is done by selecting the same Lookup order and populating the JSON Path with the same value.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio-264-0-0-production-enus/f526eaa8-ae05-487a-8944-4bb99b0b78ac/images/icon_note.png)

Note

The JSON path can be any text but a best practice is to name the JSON Path the object being referenced.

**Deep Query**

To create a Deep query, the Lookup Order is put in sequential order. Omniscript builds smaller query sets at each order set.

**Example Deep Query**

![image](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio-264-0-0-production-enus/f526eaa8-ae05-487a-8944-4bb99b0b78ac/omnistudio/images/salesforce_omniscript_deepquery.png)

In the example Deep query we are search for Leads that have Country = "USA" AND City = "San Francisco".

The from that data set we also only display Leads that have Industry = "Government". Since we are performing a Deep Query the JSON Path Field Name needs to be updated to populate Accordingly.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio-264-0-0-production-enus/f526eaa8-ae05-487a-8944-4bb99b0b78ac/images/icon_note.png)

Note

The JSON path in the Field Population property section must match the text used in the JSON Path. A best practice is to separate the JSON Path with a colon to indicate the nested JSON Path.

**OR Join**

OR Joins are not currently supported from within the Omniscript editor so a workaround must be used to accomplish this functionality. To perform an OR Join, a custom formula field on the object can be implemented to accomplish the OR portion of the query such that the formula will return either a TRUE value if the OR query is met and FALSE if not.

**Example with an OR Join**

![image](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio-264-0-0-production-enus/f526eaa8-ae05-487a-8944-4bb99b0b78ac/omnistudio/images/salesforce_omniscript_orjoin.png)

```

The Vlocity_Industry__c formula field example uses this syntax:
IF(
OR(
ISPICKVAL(Industry, "Government"),
ISPICKVAL(Industry, "Insurance"),
ISPICKVAL(Industry, "Communications")

),

"TRUE",

"FALSE")
```

This effectively allows for an OR join even though the Omniscript element doesn't support this functionality directly.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio-264-0-0-production-enus/f526eaa8-ae05-487a-8944-4bb99b0b78ac/images/icon_note.png)

Note

In all instances, Filter Values must be text and wrapped in double quotations.