CreateObject
This function instantiates the specified Marketing Cloud API Object.
NOTE: Instantiated objects do not persist after the first subsequent Invoke function call (for example,
InvokeRetrieve()
,InvokeUpdate()
, etc.).
Argument
CreateObject(1)
Ordinal | Type | Required | Description |
---|---|---|---|
1 | String | True | The name of the API Object to instantiate |
Example
The following example retrieves all of the DataExtenion
objects in a specific DataFolder (CategoryID
). The CreateObject()
line specifies the object to instantiate.
%%[
var @rr, @CategoryID, @Name, @CustomerKey
set @rr = CreateObject("RetrieveRequest")
SetObjectProperty(@rr, "ObjectType", "DataExtension")
AddObjectArrayItem(@rr, "Properties", "CategoryID")
AddObjectArrayItem(@rr, "Properties", "Name")
AddObjectArrayItem(@rr, "Properties", "CustomerKey")
set @sfp = CreateObject("SimpleFilterPart")
SetObjectProperty(@sfp, "Property", "CategoryID")
SetObjectProperty(@sfp, "SimpleOperator", "equals")
AddObjectArrayItem(@sfp, "Value", "13755")
SetObjectProperty(@rr,"Filter", @sfp)
set @rows = InvokeRetrieve(@rr, @rrStatus, @rrRequestID)
output(concat("rrStatus: ", @rrStatus))
output(concat("<br>rrRequestID: ", @rrRequestID))
for @i = 1 to RowCount(@rows) do
set @row = Row(@rows, @i)
set @CategoryID = Field(@row, "CategoryID")
set @Name = Field(@row,"Name")
set @CustomerKey = Field(@row, "CustomerKey")
output(concat("<br>CategoryID: ", @CategoryID, ", Name: ", @Name, ", CustomerKey: ", @CustomerKey))
next @i
]%%
Output
rrStatus: OK
rrRequestID: 677010b6-69d4-4839-bf59-b342d3440ca5
CategoryID: 13755, Name: LoyaltyMembers, CustomerKey: LoyaltyMembers
CategoryID: 13755, Name: CouponCodes, CustomerKey: CouponCodes