Newer Version Available

This content describes an older version of this product. View Latest

Lookup Post Input

Get lookup field suggestions.
Example: Search Dependent Lookups for Suggestions using the request body
Some lookup fields have lookup filters that restrict their valid values by referencing fields on the source object. These fields are called dependent lookups. For example, you can filter the Case Contact field to show only contacts that are associated with the account selected in the Case Account Name field.
In the Salesforce UI, this lookup filter is Contact Name: Account Name ID EQUALS Case: Account Name ID. In the User Interface API, lookup filter information appears in the filteredLookupInfo property of the Object Info response body, which is returned from several resources, including /ui-api/record-ui/{recordIds}. If the filteredLookupInfo property is non-null, the field it describes is a dependent lookup.
In this example, the Case object’s ContactId field has a filteredLookupInfo property containing a controllingFields property. The controlling field is AccountId. To restrict the lookup search, you must pass all controlling fields and their values to the lookups resource in the sourceRecord request body property.
1"objectInfos" : {
2    ...
3    "Case" : {       
4      "apiName" : "Case",
5      ...
6      "fields" : {
7       ...
8        "ContactId" : {
9          "apiName" : "ContactId",
10          ...properties removed for space...
11          "filteredLookupInfo" : {
12            "controllingFields" : [ "AccountId" ],
13            "dependent" : true,
14            "optionalFilter" : false
15          },
16          ...
17          "sortable" : true,
18          "unique" : false,
19          "updateable" : true
20        },
21        ...
To get the value for AccountId, look in the Record response body, which is returned from several resources, including /ui-api/record-ui/{recordIds}. For example, to retrieve the value of the AccountId field present on the Case 500R0000000bKpBIAU:
1GET /ui-api/records/500R0000000bKpBIAU?fields=Case.AccountId
1{
2  "apiName": "Case",
3  "id": "500Z7000000bhdFIAQ",
4  "fields": {
5    "AccountId": {
6      "displayValue": null,
7      "value": "001R0000003IG0MIAW"
8    }
9  },
10  ...Some properties removed for space...
11}
To filter the suggestions for a dependent lookup, specify the names and values of the controlling fields in the sourceRecord request body property. (This example has one controlling field).
Request body:
1POST /ui-api/lookups/case/ContactId
2{
3    "sourceRecord": {
4        "fields": {
5            "Id": "500Z7000000bhdFIAQ",
6            "AccountId": "001R0000003IG0MIAW"
7        }
8    },
9     "orderBy": [
10        {
11           "fieldApiName": "Name", 
12           "isAscending":true
13        }
14     ]  
15}
Properties
Name Type Description Required or Optional Available Version
orderBy List Order By Input[] Information describing how to order the results. Optional 63.0
sourceRecord Record Input The source record in which the lookup relationship field is being edited.

The presence of the source record “Id” is required within the “fields” property. Accepted values are “null” when creating a new record and a valid record ID when updating an existing record.

Some lookup fields have lookup filters that restrict the values they can accept by referencing fields on the source object. These fields are called dependent lookup fields or controlling fields. You must pass all controlling fields and their values to the lookups resource within the “fields” property.

To know whether a field is a lookup controlling field, check the Object Info response body for a non-null filteredLookupInfo property. Get the field values from the Record response body. Both responses are returned from the /ui-api/record-ui/{recordIds} resource.

Properties “allowSaveOnDuplicate” and “apiName” are not used.
Required 60.0