InvokeCreate()

Invokes the Create method on an API object and returns an API status code.

Availability 

Marketing Cloud Engagement ✅ Yes
Marketing Cloud Next ❌ No

Syntax 

1InvokeCreate(apiObject,
2             statusMessage,
3             errorCode,
4             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.

1%%[
2  Var @emailaddr
3  Set @emailaddr = 'help@example.com'
4
5  Set @ts = CreateObject('TriggeredSend')
6
7  Set @tsDef = CreateObject('TriggeredSendDefinition')
8
9  Set @ts_subkey = @emailaddr
10  SetObjectProperty(@tsDef, 'CustomerKey', 'VolConfirm')
11  SetObjectProperty(@ts, 'TriggeredSendDefinition', @tsDef)
12
13  Set @ts_sub = CreateObject('Subscriber')
14  SetObjectProperty(@ts_sub, 'EmailAddress', @emailaddr)
15  SetObjectProperty(@ts_sub, 'SubscriberKey', @ts_subkey)
16  AddObjectArrayItem(@ts, 'Subscribers', @ts_sub)
17
18  Set @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)
19
20  If @ts_statusCode != 'OK' then
21    RaiseError(@ts_statusMsg, 0, @ts_statusCode, @errorCode)
22  EndIf
23]%%

In this example, the AMPscript returns errors to the screen.

See Also