InvokeUpdate
Runs the SOAP API Update on a CreateObject-built handle and returns the OverallStatus. Runtime-proven on a live Marketing Cloud Engagement CloudPage against a throwaway data extension.
Syntax
InvokeUpdate(apiObject, @statusMessage, @errorCode[, updateOptions]) → string
Executes the SOAP Update on an object built with CreateObject. Returns the OverallStatus string and writes the message and numeric code to out-variables.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
apiObject |
object | Yes | The built SOAP object to update |
@statusMessage |
string | No | Out-variable that receives the status message |
@errorCode |
string | No | Out-variable that receives the numeric error code |
updateOptions |
object | No | An optional UpdateOptions object |
Example
%%[
VAR @de, @msg, @err
SET @de = CreateObject("DataExtension")
SetObjectProperty(@de, "CustomerKey", "MY_SCRATCH_DE")
SetObjectProperty(@de, "Description", "updated description")
OutputLine(Concat("ret=[", InvokeUpdate(@de, @msg, @err), "] msg=[", @msg, "] err=[", @err, "]"))
]%%
Renders ret=[OK] msg=[Data Extension updated.] err=[0].
Return value
string — the SOAP OverallStatus, OK or Error. On success @statusMessage holds the human message (e.g. Data Extension updated.) and @errorCode holds 0.
Behaviour
OK on success, out-variables populated. Updating the description of an existing throwaway data extension (via a fresh handle keyed to the same CustomerKey) returned OK, @statusMessage = Data Extension updated., @errorCode = 0.
Only the properties you set are sent. The update handle carried only the CustomerKey and the changed Description; that was enough to update just that field.
Show test script
%%[
VAR @b
SET @b = RequestParameter("b")
IF @b == "zzz" THEN
OutputLine(Concat("CTRL=[alive]"))
ENDIF
IF @b == "update" THEN
VAR @de, @m, @e, @f, @de2, @de3, @dm
/* create the throwaway DE first */
SET @de = CreateObject("DataExtension")
SetObjectProperty(@de, "CustomerKey", "AMPWSPROXYSCRATCH")
SetObjectProperty(@de, "Name", "AMPWSPROXYSCRATCH")
SetObjectProperty(@de, "Description", "v1")
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)
InvokeCreate(@de, @m, @e)
/* update the description via a fresh handle keyed the same */
SET @de2 = CreateObject("DataExtension")
SetObjectProperty(@de2, "CustomerKey", "AMPWSPROXYSCRATCH")
SetObjectProperty(@de2, "Description", "v2 UPDATED")
OutputLine(Concat("update ret=[", InvokeUpdate(@de2, @m, @e), "] msg=[", @m, "] err=[", @e, "]"))
/* clean up */
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
- SSJS Platform function
InvokeUpdate— the same-named 1:1 SSJS counterpart of this AMPscript function CreateObject·SetObjectProperty— build the objectInvokeCreate·InvokeDelete— the rest of the write lifecycle- Official reference · ampscript.guide