1

I have a scenario where i have to get user records related to the contact and populate it as dynamic content in the email template through Ampscript Code

%%[ 
var @ContactTable, @ContactRow, @OwnerTable, @OwnerRow, @Id, @FirstName, @REmail, @RName @LastName, @Email 
set @ContactTable = RetrieveSalesforceObjects("Contact","ID,FirstName,LastName,Email","Id", "=", ID)
set @ContactRow = ROW(@ContactTable,1) 
set @Id = FIELD(@ContactRow,"ID") 
set @OwnerTable = RetrieveSalesforceObjects("User","Name,Email","Id", "=", @ID) 
set @OwnerRow = Row(@OwnerTable,1) 
set @RName = FIELD(@OwnerRow,"Name") 
set @REmail = FIELD(@OwnerRow,"Email") 
]%%
Your Owner's Name is %%=v(@RName)=%% 
Your Owner's Email is %%=v(@REmail)=%%

I tried the above code but still its not populating anything

Note: I tried this using profile management mapping method its working but it is not working when I use Ampscript code

1
  • Hi @Josyula can you please confirm how are you getting the ID within the RetrieveSalesforceObject for Contact. I see it is set as the DE field value. Oct 25, 2017 at 3:49

1 Answer 1

0

Expanding on what @Brad mentioned in his comment, you need to verify your lookup keys. You're also missing a comma after @RName in your variable declarations.

%%[ 
var @ContactTable, @ContactRow, @OwnerTable
var @OwnerRow, @FirstName, @REmail, @RName
var @LastName, @Email, @id1, @id2

set @id1 = AttributeValue("ID")
output(concat("<br>id1:", @id1))

set @ContactTable = RetrieveSalesforceObjects("Contact","ID,FirstName,LastName,Email","Id", "=", @id)
set @ContactRow = ROW(@ContactTable,1) 
set @Id2 = FIELD(@ContactRow,"ID") 
output(concat("<br>id2:", @id1))

set @OwnerTable = RetrieveSalesforceObjects("User","Name,Email","Id", "=", @id2) 
set @OwnerRow = Row(@OwnerTable,1) 
set @RName = FIELD(@OwnerRow,"Name") 
set @REmail = FIELD(@OwnerRow,"Email") 
]%%
Your Owner's Name is %%=v(@RName)=%% 
Your Owner's Email is %%=v(@REmail)=%%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .