InvokeRetrieve

This function retrieves the instantiated Marketing Cloud API Object RetrieveRequest. It returns a status message and a RequestID value.

Arguments

InvokeRetrieve(1,2,3)

Ordinal Type Required Description
1 API Object True The API Object to be retrieved
2 String False The AMPscript variable in which the resulting status message is stored
3 Variable False The AMPscript variable in which the resulting RequestID is stored

Example

The following example retrieves a list of column names in the LoyaltyMembers Data Extension.

Data Extension: LoyaltyMembers

Name Data Type Length Primary Key Nullable Default Value
EmailAddress EmailAddress 254 N N
SubscriberKey Text 254 Y N
FirstName Text 50 N Y
LastName Text 50 N Y
Region Text 50 N Y
Rank Number N Y
Created Date N Y Current Date
Updated Date N Y
%%[

var @rr, @ID, @Name
set @rr = CreateObject("RetrieveRequest")
SetObjectProperty(@rr, "ObjectType", "DataExtensionField")
AddObjectArrayItem(@rr, "Properties", "Name")

set @sfp = CreateObject("SimpleFilterPart")
SetObjectProperty(@sfp, "Property", "DataExtension.CustomerKey")
SetObjectProperty(@sfp, "SimpleOperator", "equals")
AddObjectArrayItem(@sfp, "Value", "LoyaltyMembers")

SetObjectProperty(@rr,"Filter", @sfp)

set @dataExtensions = InvokeRetrieve(@rr, @rrStatus, @rrRequestID)

output(concat("rrStatus: ", @rrStatus))
output(concat("<br>rrRequestID: ", @rrRequestID))

for @i = 1 to RowCount(@dataExtensions) do

  set @dataExtension = Row(@dataExtensions, @i)
  set @Name = Field(@dataExtension, "Name")

  output(concat("<br>Name: ", @Name))

next @i

]%%

Output

rrStatus: OK
rrRequestID: d85dedfd-0833-4fe2-bcb1-3a25ad059759
Name: Updated
Name: Created
Name: FirstName
Name: SubscriberKey
Name: Rank
Name: Region
Name: LastName
Name: EmailAddress