I would like to fetch the field data in my email template from Service cloud person account. There is no syntax error, however it's not returning any values.

I also tried with Contact object in 'RetrieveSalesforceObjects' function, however it shows invalid field name error.

Can anyone help with this?


SET @Id = AttributeValue("Id") /*ContactID from DE*/

set @subscriberRows = RetrieveSalesforceObjects(
   "Id", "=", @Id )

if RowCount(@subscriberRows) == 1 then /* there should only be one row */
  set @subscriberRow = Row(@subscriberRows, 1)
  set @Store = Field(@subscriberRows,"Store__pc")


1 Answer 1


You seem to be mixing two different IDs here:

  • ContactID in the context of Marketing Cloud is an integer
  • Id of an Account object which is a string in the format of 001+15characters

If the ContactID you have stored in your DE is a number, it's the MC Contact ID and it's natural you will not find any matching records of the Account object with the same value in the Id field.

In out of the box integration the MC-type ContactID is not stored in Sales / Service Cloud, so this might be kind of a dead end if you can only rely on an integer Contact ID

You would be much better off using a Marketing Cloud Subscriber Key or Contact Key which in standard integrations using MC Connect represents the ID of the Contact object in a Salesforce org. This type of ID uses the 003+15characters format.

In a person account setup, this value is stored on the PersonContactID field in Sales Cloud.

Updated based on OP's comment:

In your original code we see you retrieving the store information from the Account object where it's named Store__pc. The __pc suffix means that for this PersonAccount this particular field was created on the level of the PersonContact (pc), so you actually have two ways of retrieving this information through ampscript:

From the Account object:

    "PersonContactID", "=", @Id)

The 003... ID is stored in the PersonContactID field

From the Contact object:

    "Id", "=", @Id)

The 003... ID is the ID of the Contact and since you are retrieving the field data from the object to which the field belongs, you need to use Store__c instead of Store__pc

  • Thanks for your reply. I use salesforce data entry event in Journey which is created on ContactPointConsent object. This object doesn't have 'Store__pc' data. I can take contact ID from this object and get other values through Ampscript. How can I do it in Ampscript? My contact ID is the ContactID from SF which starts with 003. May 30, 2022 at 20:41
  • @salesforce-user I updated my answer based on your comment May 31, 2022 at 6:01
  • it worked, thanks @Rafał Wolsztyniak May 31, 2022 at 10:31

You must log in to answer this question.

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