0

I am creating a journey for which the entry event is a salesforce data event on a contact object. But I have to use child object field data in the mail to personalize the mail.

For example

Parent object: Contact
Fields: Firstname, Lastname, Email, ContactId
Child object: Team
Fields: TeamId, TeamName, ContactId(lookup)

So how I can use the Team object data in the mail while journey's entry event is salesforce data on contact object?

I tried with ampscript following this article: Personalize email using standard object

I have used the similar code mentioned in the link given above.But I am getting these errors.

Error 1: Script SET Statement Invalid An error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: SObject

Error 2: Script SET Statement Invalid An error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: RecordId MemberID: JobID: 0 An unrecognized expression appears in a script block. Script Expression: RecordId. Invalid Content: Set @TeamRecordId = RecordId There is an error in your email. Please contact your customer service representative.

Error 3: Script SET Statement Invalid An error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: RetrieveSalesforceObjects(SObject,'TeamName,TeamId','Id', '=', RecordId) The specified attribute or custom object field name was not found for this client.

1
  • please share your code for us to give an informed answer. - "similar to X" is too broad a description of what you've done so far. At this stage what I can say the solution is probably... similar to the working example? If you get what I mean :) May 13 at 7:15

1 Answer 1

0

I've been able to figure out what was wrong. Please check the code right below that might help others.

%%[
var @Rows, @Row, @ContactId, @TeamID, @Name 
set @ContactId= ContactId
set @Rows = RetrieveSalesforceObjects("Team" , "TeamId, Name", "ContactId", "=", @ContactId)
If RowCount(@Rows) > 0 then
Set @Row = Row(@Rows, 1)
Set @TeamId= FIELD(@Row, "TeamId")
Set @Name = FIELD(@Row, "Name")
endif
]%%

For more information https://ampscript.guide/retrievesalesforceobjects/

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.