Invokes the Update method on an API object.
Availability
<table> <tr> <td>Marketing Cloud Engagement</td> <td>✅ Yes</td> </tr> <tr> <td>Marketing Cloud Next</td> <td>❌ No</td> </tr> </table>Syntax
statusMessage,
errorCode,
updateOptions)
The InvokeUpdate() function has four parameters:
apiObject(API object): Required. The API object to update.statusMessage(AMPscript variable): An AMPscript variable that stores the API status message.errorCode(AMPscript variable): An AMPscript variable that stores the response error code (if one occurs).updateOptions(API object): An UpdateOptions API object.
Usage
This example creates a new Subscriber object and sets the EmailAddress and SubscriberKey values. Next, it creates a new ClientId object, sets the value of ID, and associates the ClientId object with the Subscriber object. After that, it calls the InvokeUpdate() function to perform the update operation.
%%[
Set @sub = CreateObject("Subscriber")
SetObjectProperty(@sub,"EmailAddress", @email)
SetObjectProperty(@sub,"SubscriberKey", @subkey)
SetObjectProperty(@sub,"Status","Active")
Set @cid = CreateObject("ClientID")
SetObjectProperty(@cid, "ID", "1234567")
SetObjectProperty(@cid, "IDSpecified", "true")
SetObjectProperty(@sub, "Client", @cid)
Set @options = CreateObject("UpdateOptions")
Set @save = CreateObject("SaveOption")
SetObjectProperty(@save,"SaveAction","UpdateAdd")
SetObjectProperty(@save,"PropertyName","*")
AddObjectArrayItem(@options,"SaveOptions", @save)
Set @update_sub = InvokeUpdate(@sub, @update_sub_status, @update_sub_errorcode, @options)
]%%
<p>Status: %%=v(@update_sub_status)=%%</p>
<p>Error code: %%=v(@update_sub_errorcode)=%%</p>
If the function executes successfully, the output includes a status message and an error code of 0.
Status: Updated Subscriber.
Error code: 0