Summary
AddObjectArray()
CreateObject()
InvokeCreate()
InvokeDelete()
InvokeExecute()
InvokePerform()
InvokeRetrieve()
InvokeUpdate()
SetObjectProperty()
Invokes the Update method on an API object.
| Marketing Cloud Engagement | ✅ Yes |
| Marketing Cloud Next | ❌ No |
1statusMessage,
2 errorCode,
3 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.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.
1%%[
2 Set @sub = CreateObject("Subscriber")
3 SetObjectProperty(@sub,"EmailAddress", @email)
4 SetObjectProperty(@sub,"SubscriberKey", @subkey)
5 SetObjectProperty(@sub,"Status","Active")
6
7 Set @cid = CreateObject("ClientID")
8 SetObjectProperty(@cid, "ID", "1234567")
9 SetObjectProperty(@cid, "IDSpecified", "true")
10 SetObjectProperty(@sub, "Client", @cid)
11
12 Set @options = CreateObject("UpdateOptions")
13 Set @save = CreateObject("SaveOption")
14 SetObjectProperty(@save,"SaveAction","UpdateAdd")
15 SetObjectProperty(@save,"PropertyName","*")
16 AddObjectArrayItem(@options,"SaveOptions", @save)
17
18 Set @update_sub = InvokeUpdate(@sub, @update_sub_status, @update_sub_errorcode, @options)
19]%%
20<p>Status: %%=v(@update_sub_status)=%%</p>
21<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.
1Status: Updated Subscriber.
2Error code: 0