InvokePerform()

Invokes the Perform method on a Marketing Cloud Engagement API Object and returns the API status code.

Availability

<table> <tr> <td>Marketing Cloud Engagement</td> <td>✅ Yes</td> </tr> <tr> <td>Marketing Cloud Next</td> <td>❌ No</td> </tr> </table>

Syntax

InvokePerform(apiObject,
              actionToPerform,
              statusMessage)

The InvokePerform() has three parameters:

  • apiObject (API Object): Required. The API Object to invoke the Perform method on.
  • actionToPerform (string): Required. Action to perform, with valid parameter values varying depending on the object type.
  • statusMessage (AMPscript variable): An AMPscript variable that stores the API status message.

Usage

This example creates a Campaign API Object and sets a property on it. It then invokes the Perform method on the Object, passing the "stop" action. The function then outputs the status code. If the status code doesn’t equal "OK," it outputs the status message and error code.

%%[
  var @campaign, @statusCode, @statusMessage, @errorCode, @campaignId

  set @campaignId = 1
  set @campaign = CreateObject("Campaign")

  SetObjectProperty(@campaign, "ID", @campaignId)

  Set @statusCode = InvokePerform(@campaign, "stop", @statusMessage)
]%%

<p>Status Code: %%=v(@statusCode)=%%</p>

%%[If @statusCode != "OK" then]%%

<p>Status Message: %%=v(@statusMessage)=%%</p>
<p>Error Code: %%=v(@errorCode)=%%</p>
%%[EndIf]%%