Invokes the Delete method on a Marketing Cloud Engagement API Object and returns the API status code. Use an ID, external ID, or key as the object reference.
Availability
<table> <tr> <td>Marketing Cloud Engagement</td> <td>✅ Yes</td> </tr> <tr> <td>Marketing Cloud Next</td> <td>❌ No</td> </tr> </table>Syntax
InvokeDelete(apiObject,
statusMessage,
errorCode,
deleteOptionsObject)
The InvokeDelete() function has four parameters:
apiObject(API Object): Required. The API Object to delete.statusMessage(AMPscript variable): Required. An AMPscript variable that stores the API status message.errorCode(AMPscript variable): Required. An AMPscript variable that stores the API error code.deleteOptionsObject(API Object): A DeleteOptions API object.
Usage
This example creates a Subscriber API Object and sets a property on it. It then deletes the Object and outputs the status code. If the status code doesn’t equal "OK," it outputs the status message and error code.
%%[
var @sub, @statusCode, @statusMessage, @errorCode
set @sub = CreateObject("Subscriber")
SetObjectProperty(@sub, "CustomerKey", "4231")
set @statusCode = InvokeDelete(@sub, @statusMessage, @errorCode)
]%%
<p>Status Code: %%=v(@statusCode)=%%</p>
%%[If @statusCode != "OK" then]%%
<p>Status Message: %%=v(@statusMessage)=%%</p>
<p>Error Code: %%=v(@errorCode)=%%</p>
%%[EndIf]%%