Runtime verified Test scripts included

Syntax

InvokeCreate(apiObject, @statusMessage, @errorCode[, createOptions])  →  string
3–4 arguments

Executes the SOAP Create on an object built with CreateObject. Returns the OverallStatus string and writes the human-readable message and numeric code to out-variables.

Parameters

Name Type Required Description
apiObject object Yes The built SOAP object to create
@statusMessage string Yes Out-variable that receives the status message
@errorCode string Yes Out-variable that receives the numeric error code
createOptions object No An optional CreateOptions object

Example

%%[
  VAR @de, @msg, @err
  SET @de = CreateObject("DataExtension")
  SetObjectProperty(@de, "CustomerKey", "MY_SCRATCH_DE")
  SetObjectProperty(@de, "Name", "MY_SCRATCH_DE")
  VAR @f
  SET @f = CreateObject("DataExtensionField")
  SetObjectProperty(@f, "Name", "Id")
  SetObjectProperty(@f, "FieldType", "Text")
  SetObjectProperty(@f, "MaxLength", "50")
  SetObjectProperty(@f, "IsPrimaryKey", "true")
  SetObjectProperty(@f, "IsRequired", "true")
  AddObjectArrayItem(@de, "Fields", @f)
  OutputLine(Concat("ret=[", InvokeCreate(@de, @msg, @err), "] msg=[", @msg, "] err=[", @err, "]"))
]%%

Renders ret=[OK] msg=[Data Extension created.] err=[0].

Return value

string — the SOAP OverallStatus, one of OK or Error. On success the @statusMessage out-variable holds the human message (e.g. Data Extension created.) and @errorCode holds 0.

Behaviour

OK on success, out-variables populated. Creating a throwaway data extension returned OK, with @statusMessage = Data Extension created. and @errorCode = 0.

The return is a closed two-token set. Across the create/update/delete/perform family the OverallStatus was only ever OK (success) or Error (failure).

Show test script
%%[
  VAR @b
  SET @b = RequestParameter("b")

  IF @b == "zzz" THEN
    OutputLine(Concat("CTRL=[alive]"))
  ENDIF

  IF @b == "create" THEN
    VAR @de, @m, @e, @f, @de3, @dm
    SET @de = CreateObject("DataExtension")
    SetObjectProperty(@de, "CustomerKey", "AMPWSPROXYSCRATCH")
    SetObjectProperty(@de, "Name", "AMPWSPROXYSCRATCH")
    SET @f = CreateObject("DataExtensionField")
    SetObjectProperty(@f, "Name", "Id")
    SetObjectProperty(@f, "FieldType", "Text")
    SetObjectProperty(@f, "MaxLength", "50")
    SetObjectProperty(@f, "IsPrimaryKey", "true")
    SetObjectProperty(@f, "IsRequired", "true")
    AddObjectArrayItem(@de, "Fields", @f)
    OutputLine(Concat("create ret=[", InvokeCreate(@de, @m, @e), "] msg=[", @m, "] err=[", @e, "]"))
    /* clean up the throwaway DE */
    SET @de3 = CreateObject("DataExtension")
    SetObjectProperty(@de3, "CustomerKey", "AMPWSPROXYSCRATCH")
    OutputLine(Concat("cleanup ret=[", InvokeDelete(@de3, @dm, @e), "]"))
  ENDIF
]%%

Availability

Platform Available
Marketing Cloud Engagement Yes
Marketing Cloud Next No

See also