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, whereFieldNames, whereFieldValues, fieldNames, fieldValues)
5 arguments
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
deName |
string | Yes | Data Extension name or external key |
whereFieldNames |
string|string[] | Yes | Column name(s) to identify the rows to update; use an array for multiple columns (AND logic) |
whereFieldValues |
string|array | Yes | Value(s) to match in whereFieldNames; must be an array of equal length when whereFieldNames is an array |
fieldNames |
string[] | Yes | Array of column names to update |
fieldValues |
array | Yes | Array of new values aligned to fieldNames |
Examples
Update a single column
var affected = Platform.Function.UpdateData(
"Subscribers",
["SubscriberKey"], [subscriberKey], // filter: rows where SubscriberKey = subscriberKey
["Status"], ["unsubscribed"] // column to update
);
Write(affected + " row(s) updated.");
Update multiple columns
Platform.Function.UpdateData(
"Subscribers",
["Email"], [email], // filter: update rows where Email = email
["LastLogin", "LoginCount", "Status"],
[Now(), loginCount + 1, "active"]
);
Update with error handling
try {
var updated = Platform.Function.UpdateData(
"Orders",
["OrderID"], [orderId], // filter
["ShippedDate"], [Now()] // data to update
);
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