0

I am trying to retrieve data from a synchronised data extension with AMPScript . I have a field named Contact__c which contains the contactID. This contactID is connected to zero, one or multiple product interests (URL_Monthly__c). The product interests are displayed as an URL (<a href>).

I want to create an e-mail where the URL's are generated based on the contactID. I have the following AMPScript:

%%[

VAR @multiRows, @row, @i, @URL_Monthly__c, @Contact__c

SET @Contact__c = AttributeValue("Subscriber Key")
SET @multiRows = LookupRows("Fund_Interest__c_Salesforce",@Contact__c,Id)

%%[ 
    for @i = 1 to RowCount(@multiRows) do 
       Set @row = Row(@multiRows,@i) 
       Set @URL_Monthly__c = Field(@row,"URL_Monthly__c") ]%%

%%[ Output(v(@URL_Monthly__c)) ]%%
%%[ next @i ]%%

]%%

This AMPScript gives me the following error:

The specified attribute or custom object field name was not found for this client. Function Call: LookupRows(“Fund_Interest__c_Salesforce”,@Contact__c,Id) Attribute or Field Name: “Fund_Interest__c_Salesforce”

What am i doing wrong?

0

Try it without the curly-quotes. Those don't work in AMPScript

I'd also use the _subscriberkey personalization string in your lookupRows().

%%[

VAR @multiRows, @row, @i, @URL_Monthly__c, @Contact__c

SET @Contact__c = AttributeValue("_subscriberkey")
SET @multiRows = LookupRows("Fund_Interest__c_Salesforce","Id", @Contact__c)

%%[ 

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

   Set @row = Row(@multiRows,@i) 
   Set @URL_Monthly__c = Field(@row,"URL_Monthly__c") 
   Output(concat("<br>URL_Monthly__c: ",@URL_Monthly__c)) 

next @i 

]%%

Update for unordered list output:

%%[ 

VAR @multiRows, @row, @i, @URL_Monthly__c, @Contact__c 

SET @multiRows = LookupRows("Fund_Interest__c_Salesforce","Contact__c", _SubscriberKey) 

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

    Set @row = Row(@multiRows,@i) 
    Set @URL_Monthly__c = Field(@row,"URL_Monthly__c") 

    if @i == 1 then 
        Output(concat("<ul>")) 
    endif

    Output(concat("<li>",@URL_Monthly__c,"</li>")) 

    if @i == @rowCount then
        Output(concat("</ul>")) 
    endif  

next @i

]%% 
  • Hi Adam, Thanks for your reply. I used your AMP-script, but i am now getting the next error: The specified attribute or custom object field name was not found for this client. Function Call: LookupRows("Fund_Interest__c_Salesforce",@Contact__c,Id) Attribute or Field Name: Id. That Attribute field is in another synchronised data extensions, but I made sure that there is a relationship between those two. – Daan Kramer Dec 7 '17 at 14:50
  • Looks like you need to swap the last two lookupRows() parameters. I updated my example. – Adam Spriggs Dec 7 '17 at 17:55
  • Thanks Adam, this worked for us. Do you have any tips regarding creating a bulleted list with AMP-script? I checked your blog, but I couldn't find any documentation, thanks! – Daan Kramer Dec 11 '17 at 14:58
  • This is how I would generally structure the AMPScript. Of course, you'd want to use <li></li> instead of <h1></h1>. – Adam Spriggs Dec 11 '17 at 15:42
  • Thanks I am almost there. This is my code: code %%[ VAR @multiRows, @row, @i, @URL_Monthly__c, @Contact__c SET @multiRows = LookupRows("Fund_Interest__c_Salesforce","Contact__c", _SubscriberKey) for @i = 1 to RowCount(@multiRows) do Set @row = Row(@multiRows,@i) Set @URL_Monthly__c = Field(@row,"URL_Monthly__c") Output(concat(" URL_Monthly__c: ",@URL_Monthly__c)) next @i ]%% <li>%%=v(@URL_Monthly__c)=%%</li> It now generates two unique products for a customer, but also a bulleted list of one product. I only want the list. Thanks in advance – Daan Kramer Dec 11 '17 at 16:05

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.