InvokeExecute

This function executes the instantiated Marketing Cloud API Object. It returns a RequestID value (because it is executed asynchronously), an API Object containing a status message and an error code value.

Arguments

InvokeExecute(1,2,3)

Ordinal Type Required Description
1 API Object True The API Object to be executed
2 String True The AMPscript variable in which the resulting status message is stored
3 Variable True The AMPscript variable in which the resulting RequestID is stored

Example

The following example logs an unsubscribe event for a specific email Subscriber.

%%[

set @er = CreateObject("ExecuteRequest")
SetObjectProperty(@er,"Name","LogUnsubEvent")

set @prop = CreateObject("APIProperty")
SetObjectProperty(@prop, "Name", "SubscriberKey")
SetObjectProperty(@prop, "Value", "9496")
AddObjectArrayItem(@er, "Parameters", @prop)

set @prop = CreateObject("APIProperty")
SetObjectProperty(@prop, "Name", "Reason")
SetObjectProperty(@prop, "Value", "Hates getting emails")
AddObjectArrayItem(@er, "Parameters", @prop)

set @invokeStatusObj = InvokeExecute(@er, @invokeStatusMessage, @invokeRequestId)

SET @invokeResponse = Row(@invokeStatusObj, 1)
SET @invokeStatus = Field(@invokeResponse,'StatusMessage')
SET @invokeErrorCode = Field(@invokeResponse,'ErrorCode')

]%%
invokeStatusMessage: %%=v(@invokeStatusMessage)=%%
<br>invokeRequestId: %%=v(@invokeRequestId)=%%
<br>invokeStatus: %%=v(@invokeStatus)=%%
<br>invokeErrorCode: %%=v(@invokeErrorCode)=%%

Output

invokeStatusMessage: OK
invokeRequestId: 89d0a3ad-00b8-4347-858b-41b672984359
invokeStatus: Event posted
invokeErrorCode: 0