I want to send emails using a Salesforce Report which is based on Custom Report. I have created an AMP Script Code in order to fill some fields but I don't receive the email. This is the code:

%%[ VAR @rs, @row, @value, @date, @DateP1 
SET @date = AttributeValue("TargetX_SRMb__Application__c:Id") 
SET @rs = RetrieveSalesforceObjects('TargetX_SRMb__Application__c', 'Payment_Deadline_1__c', 'Id', '=', @date) 
IF RowCount(@rs) == 1 THEN 
SET @row = Row(@rs, 1) 
SET @value = Field(@row, 'Payment_Deadline_1__c') 
SET @DateP1 = FormatDate(@value,"l","","en-gb") 
SET @value = 'error' 

And the report is:

Salesforce Report

If I test the email using a Data Extension with the name of Salesforce fields, the email is well mapped but when I send the email to the report population, the email doesn't arrive.

Is anyone having the same issue? There is a way to solve it? I can't create a profile attribute with Application Id because it isn't in the Contact Object.

Can somebody help me?

Thank you, Anna

1 Answer 1


Two things here:

  1. You're using AttributeValue("TargetX_SRMb__Application__c:Id") - this fields has to be present either as a Profile Attribute or in the Sendable Data Extension. If this field is not present in your report (which creates a temporary Data Extension), the script won't be able to find this value and the send will fail. Try using a lookup to a Synchronized Data Extension if this field is not present in your Sendable DE. If this is a separate object or a field on an object which isn’t yet synchronized, synchronize it as well in Contact Builder. If this field is present in your report, find the underlying Data Extension and check the exact field name in that DE, not in the report, and use that field name in the AttributeValue function.

  2. You shouldn't use RetrieveSalesforceObjects in an email. It might work fine when you send out a test, but then if you send this email to a larger audience, it will take ages for those emails to send. Use a lookup to a Synchronized Data Extension instead.

  • As I don't have the information in the DE, I have done someting like: SET '@ContactId' = AttributeValue ('SubscriberKey') /extract contact Id SET '@AppId' = Lookup('TargetX_SRMb__Application__c_Salesforce_2','Id','TargetX_SRMb__Contact__c',@ContactId) / Search the application Id related with that contact SET @rs = Lookup ('TargetX_SRMb__Application__c_Salesforce_2','Payment_Deadline_1__c','Id',@AppId) / extract the payment deadline<code> But it doesn't work, do you know what I do wrong? I'm not an expert in AMP Script and it is difficult to me... Thanks! Nov 12, 2019 at 15:40
  • Take out the apostrophe around @ContactId and @AppId - the rest seems fine, as long as you got DE names right
    – zuzannamj
    Nov 12, 2019 at 16:29
  • Hi @zuzannamj I have written de apostrophe before the variables because the system didn't allow me post a comment. Thank you so much for your answer, the code didn't work but i'm going to look for what is wrong. Nov 12, 2019 at 16:41
  • 1
    @AnnaJourneys I noticed that you have a space in the second lookup, try without the space: @rs = Lookup('TargetX_SRMb__Application__c_Salesforce_2','Payment_Deadline_1__c','Id',@AppId)
    – zuzannamj
    Nov 13, 2019 at 14:38

You must log in to answer this question.

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