Skip to main content
Function Lookup()

Get a field value of a record from another object that is linked via a lookup field

Erik avatar
Written by Erik
Updated over a week ago

Use Lookup() to retrieve the value of a field from the record referenced by a lookup field.

How to use

  • Lookup(lookupIDFieldApiName, targetFieldApiName)

Input

  • lookupIDFieldApiName: API name of the lookup field containing the ID of the referenced the record which contains the target field whose value is being retrieved

  • targetFieldApiName - API name of the field in the referenced record whose value to retrieve

Output

The value of the requested field.

Example

Let's assume you created a Check in button for an Account object that has a lookup field with the API name Primary_Contact in your data source referencing the Contact object, and you'd like to programmatically retrieve the first name of the primary contact (a field with the API name First_Name in the Contact object). When the Check In button is clicked for an account, you'll be able to do this with this code:

Lookup('record.Primary_Contact_ID', 'First_Name')
​
​NOTE. Why are we using Primary_Contact_ID here?
​
When Mapsly imports a lookup field from a data source (for example, Primary_Contact), it creates several fields in Mapsly by adding _ID, _NAME and _TYPE to the original name of the lookup field:

  • Primary_Contact_ID, a field that contains the ID of the referenced record;

  • Primary_Contact_NAME, a field that contains the name of the referenced record (the name is retrieved from the fields mapped as Name in the referenced object in Mapsly);

  • [Only for polymorphic lookups] Primary_Contact_TYPE, a field containing the API name of the object referenced by the lookup field.
    ​
    A polymorphic lookup is a lookup that may reference one of several objects, as opposed to a simple lookup that references the same object from all records. For example, a Salesforce object Meeting has WhoId and WhatId polymorphic lookups fields, which may reference Lead/Contact and Account/Opportunity objects, respectively.

See also

Did this answer your question?