1

I do want to remove the time from a Salesforce field retrieved from the object CampaignMember.

I had tried this the following amspcript code in my email but I do still have errors to send it :

%%[
VAR @MemberId, @IdCamp, @SubscriberKey, @datecreationdevis,
SET @codecampagne = 'TRI'
SET @CampaignmemberId = AttributeValue("CampaignMember:Id")
SET @IdCamp = AttributeValue("CampaignMember:Campaign:Id")
SET @SubscriberKey = AttributeValue("CampaignMember:Contact:Id")
SET @datecreationdevis = FormatDate(CampaignMember:OpportunityCreationDate__c, "DD/MM/YYYY", "fr-FR")
]%% 

Bonjour %%CampaignMember:FirstName%% %%CampaignMember:LastName%%, 

Suite au devis présenté le %%@datecreationdevis%%, j'aimerais vous proposer un RDV prochainement

1 Answer 1

4

Try this:

%%[
VAR @MemberId, @IdCamp, @SubscriberKey, @datecreationdevis,
SET @codecampagne = 'TRI'
SET @CampaignmemberId = AttributeValue("CampaignMember:Id")
SET @IdCamp = AttributeValue("CampaignMember:Campaign:Id")
SET @SubscriberKey = AttributeValue("CampaignMember:Contact:Id")
SET @OpportunityCreationDate = AttributeValue("CampaignMember:OpportunityCreationDate__c")
SET @datecreationdevis = FormatDate(@OpportunityCreationDate, "DD/MM/YYYY", "fr-FR")
]%% 

Bonjour %%CampaignMember:FirstName%% %%CampaignMember:LastName%%, 

Suite au devis présenté le %%=v(@datecreationdevis)=%%, j'aimerais vous proposer un RDV prochainement

Inside the FormatDate function, you just put the Data Extension field name, without declaring it as a variable first or without using the quotation marks, which would tie it to your Sendable DE, that's why it didn't know where to pull the date from. This should now work.

6
  • thanks for your reply . I had checked if the field is in the Sendable Date Extension (generated by Salesforce) has the same name as CampaignMember:OpportunityCreationDate__c and the name is the same but I still do have the error "there is an error sending the email" Sep 5, 2022 at 15:28
  • Please try now, I’ve updated the script in my original answer - you were using inline AMPscript incorrectly in the last line
    – zuzannamj
    Sep 5, 2022 at 15:35
  • Hi @zuzannamj, the formatting code works but I still have an issue. The output is '05/09/2022' (the format that I wanted) followed by '0r-R'. Would you know why '0r-R' appears on my email ? Have you already encounter this '0r-R' ? Sep 5, 2022 at 16:21
  • Not sure but it must come from the “FR-fr” parameter - why don’t you try without it? FormatDate(@OpportunityCreationDate, "DD/MM/YYYY")
    – zuzannamj
    Sep 5, 2022 at 16:46
  • Hi@zuzannamj, I have changed the ampscript code to that : @datecreationdevis = FormatDate(@OpportunityCreationDate, "s") and it worked. Thanks for your help Sep 6, 2022 at 8:49

You must log in to answer this question.

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