1

I have an array from where I need to retrieve specific positions values. I can see the whole array when I call it directly but when I call a position I receive this in ET: System.Data.DataRow

AMPscript block:
SET @M1_info_array = BuildRowsetFromString(@M1_info_string, '+') SET @M1_1st_company_ID = Row(@M1_info_array, 4)
HTML
ID: %%=v(@M1_1st_company_ID)=%%
Should return the value of the @M1_1st_company_ID but instead I get System.Data.DataRow.

How to fix this?

0

You are missing a step.

When you call Row(), it returns the entire row. Which is why it is not displaying right.

What you need to do is: (with value only)

SET @M1_info_array = BuildRowsetFromString(@M1_info_string, '+')
SET @Row = Row(@M1_info_array, 4)
SET @M1_1st_company_ID = Field(@Row, 1)

What you need to do is: (with name of fields)

SET @M1_info_array = BuildRowsetFromXML(@M1_info_XML, '//Merchant_ID', 1)
SET @Row = Row(@M1_info_array, 4)
SET @M1_1st_company_ID = Field(@Row, "company_ID")

The third SET (for @M1_1st_company_ID) is what will set the actual value to the variable and allow you to later call it in the HTML. You can easily replace 'company_ID' with whatever other column name or attribute you wish to call.

SFMC has a great example on using Row and Field in this help document. It involves the web API and a bit more than you really need, but gives a solid use case for you to see.

Example below:

%%[
VAR @retrieveRequest, @simpleFilterPart, @subscribers, @i, @currentSub, @currentSubAttribs, @j, @currentSubAttrib, @filter
VAR @properties, @Field1, @Field2, @numofProperties, @currentProp

/* Create and populate a RetrieveRequest */
SET @retrieveRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@retrieveRequest, "ObjectType", "DataExtensionObject[ExampleDataExtension]")

AddObjectArrayItem(@retrieveRequest, "Properties","Field1")
AddObjectArrayItem(@retrieveRequest, "Properties","Field2")

/* Execute the Retrieve */
SET @emails = InvokeRetrieve(@retrieveRequest)

SET @emailCount = RowCount(@emails)
/* Iterate over the subscribers */

]%%
<br /><br />

%%[
FOR @i = 1 to @emailCount DO
    SET @currentSub = Row(@emails, @i)
    SET @properties = Field(@currentSub,"Properties")
    Set @numofProperties = ROWCOUNT(@properties)

FOR @j = 1 to @numofProperties DO

    SET @currentProp = Row(@properties, @j)
    Set @Field1= FIELD(@currentProp ,"Name") 
    Set @Field2= FIELD(@currentProp ,"Value") 

]%%

%%[if @j == @numofProperties then ]%%
<b>%%=v(@Field2)=%%</b>
%%[else]%%
%%=v(@count)=%%:
%%[endif]%%

%%[
NEXT @j
]%%
<br /><br />
%%[
NEXT @i
]%%

references:

  • thanks Gortonington but it doesn't work, now I receive "Unable to generate preview". – Snowalker Feb 19 '16 at 16:33
  • that usually means there is an error in validating the AMPscript or in the data. Make sure the row name being called is the correct name in the XML. – Gortonington Feb 19 '16 at 16:34
  • I don't use XML. I successfully retrieved content from arrays positions in the past, not sure why now my code doesn't work. – Snowalker Feb 19 '16 at 16:40
  • Please update your question with some sample data. – Adam Spriggs Feb 19 '16 at 17:16
  • Apologies, with BuildRowset, I almost always see it being used with XML, I did not see you were using the string version. I believe I may see the disconnect and will edit my answer accordingly. – Gortonington Feb 19 '16 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.