Invokes the Create method on an API object and returns an 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
InvokeCreate(apiObject,
statusMessage,
errorCode,
createOptionsObject)
The InvokeCreate() function has four parameters:
apiObject(API Object): Required. The API Object to create.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.createOptionsObject(API Object): A CreateOptions API object.
Usage
This example creates the TriggeredSend and TriggeredSendDefinition objects as @ts and @tsDef. It also assigns the correct properties to the objects and passes the object into the InvokeCreate call. The InvokeCreate call returns a status code and status message, which you can use for handling exceptions.
%%[
Var @emailaddr
Set @emailaddr = 'help@example.com'
Set @ts = CreateObject('TriggeredSend')
Set @tsDef = CreateObject('TriggeredSendDefinition')
Set @ts_subkey = @emailaddr
SetObjectProperty(@tsDef, 'CustomerKey', 'VolConfirm')
SetObjectProperty(@ts, 'TriggeredSendDefinition', @tsDef)
Set @ts_sub = CreateObject('Subscriber')
SetObjectProperty(@ts_sub, 'EmailAddress', @emailaddr)
SetObjectProperty(@ts_sub, 'SubscriberKey', @ts_subkey)
AddObjectArrayItem(@ts, 'Subscribers', @ts_sub)
Set @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)
If @ts_statusCode != 'OK' then
RaiseError(@ts_statusMsg, 0, @ts_statusCode, @errorCode)
EndIf
]%%
In this example, the AMPscript returns errors to the screen.