verified
Lookup a Data Extension recordLearn how to lookup Data Extension records (rows) in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include Core and Platform methods.
Platform
var name = "MyDataExtension";
var result = Platform.Function.Lookup(
name,
"FirstName",
"EmailAddress",
"example@mail.com"
);
<script runat="server">
try {
var name = "MyDataExtension";
var result = Platform.Function.Lookup(
name,
"FirstName",
"EmailAddress",
"example@mail.com"
);
Platform.Response.Write(Platform.Function.Stringify(result));
} catch(error) {
Platform.Response.Write(Platform.Function.Stringify(error));
}
</script>
"John"
Core
var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";
var de = DataExtension.Init(customerKey);
var result = de.Rows.Lookup(
["EmailAddress"],
["example@mail.com"]
);
<script runat="server">
Platform.Load("core", "1");
try {
var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";
var de = DataExtension.Init(customerKey);
var result = de.Rows.Lookup(
["EmailAddress"],
["example@mail.com"]
);
Write(Stringify(result));
} catch(error) {
Write(Stringify(error));
}
</script>
[
{
"_CustomObjectKey": 1,
"SubscriberKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"FirstName": "John",
"LastName": "Doe",
"EmailAddress": "example@mail.com"
}
]
Reference
Ressources and references related to the current methods.
Official documentation
SOAP object
Help me turn coffee into code
This website is provided to you free of charge. However, a lot of time and effort are spent to write, test and mainain the code. Please consider supporting my work by buying me a cup of coffee.