Retrieves the value of a specific field from a column in a data extension.
Syntax
Platform.Function.Lookup(1, 2, 3, 4)
| Ordinal | Type | Description |
|---|---|---|
| 1 | string | Required. The name of the data extension. |
| 2 | string | Required. The name of the column that contains that value that you want to retrieve. |
| 3 | string or array | Required. The name of the column that contains the data to look up. To specify multiple column names, place the column names in an array. When you specify multiple column names, they’re connected using AND logic. |
| 4 | string or array | Required. The value to look up in the specified column. To specify multiple values, place the values in an array. If you specify an array for ordinal 3, you must specify an array of equal length for this ordinal. |
Usage
To use this function, specify the name of the data extension and the name of the column that contains the value that you want to retrieve. Next, specify the column name and value to find in the specified data extension.
These examples reference a data extension called CustomerData that contains the customer data listed in this table.
<!-- Names are drawn from the list of Salesforcelandian characters (https://confluence.internal.salesforce.com/pages/viewpage.action?pageId=668086572), with the exceptions of Taro Yamada and Anna Kowalski. These names are the equivalents of John/Jane Doe in Japanese and Polish, respectively. --> <!-- Phone numbers are fictitious and were created using the guidelines at https://en.wikipedia.org/wiki/Fictitious_telephone_number -->| ExternalId | FirstName | LastName | Phone | |
|---|---|---|---|---|
| 66057f8f-2003-4d08-8c87-b0a16a60d34e | Carolyn | Baumgartner | carolyn.baumgartner@example.com | +493023125123 |
| be22021f-69ff-4b5c-99c3-bb42193343bc | Ernesto | Rondán | ernesto.rondan@example.com | +19155550101 |
| e67e755d-d2b9-4a0e-8103-eee7958ef257 | Calvin | Green | calvin.green@example.com | +12065550042 |
| 97b40dbb-2eaa-4880-9636-1639f92318a8 | Anna | Kowalski | anna.kowalski@example.com | +33639981234 |
| 3b7e5138-75c6-4a2b-9155-598c6121d3ea | Tarō | Yamada | yamada.taro@example.com | +61491579760 |
| f86b8f65-6167-4faa-8b0c-8019e389982a | Mindy | Lee | mindy.lee@example.com | +14165550123 |
Query with a Single Column Name and Value
This example retrieves the value of the Phone column for the row in which the value of the ExternalId column is 'e67e755d-d2b9-4a0e-8103-eee7958ef257'.
<script runat="server">
var phoneNumber =
Platform.Function.Lookup('CustomerData','Phone','ExternalId','e67e755d-d2b9-4a0e-8103-eee7958ef257');
Platform.Response.Write(phoneNumber)
</script>
The function outputs the phone number for the specified customer: +12065550042.
Query with Multiple Column Names and Values
This example retrieves the value of the Phone column for the row that contains "Carolyn" in the FirstName column and "Baumgartner" in the LastName column.
<script runat="server">
var phoneNumber = Platform.Function.Lookup('CustomerData','Phone',['FirstName',
'LastName'],['Carolyn','Baumgartner']); Platform.Response.Write(phoneNumber)
</script>
The function outputs the phone number for the specified customer: +493023125123.