InvokeUpdate
This function executes an update on the instantiated Marketing Cloud API Object. It returns a status code, message and an error code.
API error codes are outlined in the official documentation.
Arguments
InvokeUpdate(1,2,3,4)
Ordinal | Type | Required | Description |
---|---|---|---|
1 | API Object | True | The API Object to be updated |
2 | Variable | False | The AMPscript variable in which the resulting status message is stored |
3 | Variable | False | The AMPscript variable in which the resulting error code is stored |
4 | API Object | False | The optional UpdateOptions API Object |
Example
The following example executes an insert or update on a Subscriber record, setting the Status to Active
. The EmailAddress
and SubscriberKey
are required for creating a new Subscriber.
%%[
var @sub, @updateStatusCode, @updateStatusMessage, @updateErrorCode
set @sub = CreateObject("Subscriber")
SetObjectProperty(@sub, "EmailAddress", "doug@limedash.com")
SetObjectProperty(@sub, "SubscriberKey", "8473")
SetObjectProperty(@sub, "Status", "Active")
set @updateOptions = CreateObject("UpdateOptions")
set @saveOptions = CreateObject("SaveOption")
SetObjectProperty(@saveOptions,"SaveAction","UpdateAdd")
SetObjectProperty(@saveOptions,"PropertyName","*")
AddObjectArrayItem(@updateOptions,"SaveOptions", @saveOptions)
set @updateStatusCode = InvokeUpdate(@sub, @updateStatusMessage, @updateErrorCode, @updateOptions)
]%%
updateStatusCode: %%=v(@updateStatusCode)=%%
<br>updateStatusMessage: %%=v(@updateStatusMessage)=%%
<br>updateErrorCode: %%=v(@updateErrorCode)=%%
Output
updateStatusCode: OK
updateStatusMessage: Updated Subscriber.
updateErrorCode: 0