UpdateData
→ numberModifies existing rows in a Data Extension that match the filter criteria. Returns the number of rows updated.
Available in:
Email
CloudPage
Automation
Triggered Send
Syntax
Platform.Function.UpdateData(deName, updateField, updateValue, filterField, filterValue [, ...])
5+ arguments
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
deName |
string | Yes | Data Extension name or external key |
updateField |
string | Yes | Column to update |
updateValue |
string | Yes | New value for the column |
filterField |
string | Yes | Column to filter on (identifies which rows to update) |
filterValue |
string | Yes | Filter value |
Additional updateField/updateValue pairs can be appended before the filter pair for updating multiple columns.
Examples
Update a single column
var affected = Platform.Function.UpdateData(
"Subscribers",
"Status", "unsubscribed", // column to update
"SubscriberKey", subscriberKey // filter
);
Write(affected + " row(s) updated.");
Update multiple columns
Platform.Function.UpdateData(
"Subscribers",
"LastLogin", Platform.Function.Now(),
"LoginCount", loginCount + 1,
"Status", "active",
"Email", email // filter: update rows where Email = email
);
Update with error handling
try {
var updated = Platform.Function.UpdateData(
"Orders",
"ShippedDate", Platform.Function.Now(),
"OrderID", orderId
);
if (updated === 0) {
Write("No order found with ID: " + orderId);
}
} catch (e) {
Write("Update failed: " + e.message);
}
Notes
- If no rows match the filter, returns
0(not an error) UpdateDEis an alias forUpdateData- For insert-or-update logic, use
UpsertData