SetObjectProperty

This function sets a property value for an object created with the CreateObject function.

Arguments

SetObjectProperty(1,2,3)

Ordinal Type Required Description
1 API Object True The API Object for which the property is set
2 String True The name of the property to set
3 String True The value of the property

Example

The following example executes an insert or update on a Subscriber record, setting the Status to Active. The SetObjectProperty() function is used to set the properties to add to or update the Subscriber object.

%%[

var @sub, @updateStatusCode, @updateStatusMessage, @updateErrorCode
set @sub = CreateObject("Subscriber")
SetObjectProperty(@sub, "EmailAddress", "barb@limedash.com")
SetObjectProperty(@sub, "SubscriberKey", "5767")
SetObjectProperty(@sub, "Status", "Active")

set @updateOptions = CreateObject("UpdateOptions")
set @saveOptions = CreateObject("SaveOption")
SetObjectProperty(@saveOptions,"SaveAction","UpdateAdd")
SetObjectProperty(@saveOptions,"PropertyName","*")
AddObjectArrayItem(@updateOptions,"SaveOptions", @saveOptions)

set @updateStatusCode = InvokeUpdate(@sub, @updateStatusMessage, @updateErrorCode, @updateOptions)

]%%
updateStatusCode: %%=v(@updateStatusCode)=%%
<br>updateStatusMessage: %%=v(@updateStatusMessage)=%%
<br>updateErrorCode: %%=v(@updateErrorCode)=%%

Output

updateStatusCode: OK
updateStatusMessage: Updated Subscriber.
updateErrorCode: 0