Format Salesforce Date Token
The Problem
Sometimes Date fields do not display the way you want them to in PandaDoc. This is due to the way the data is saved in Salesforce.
You can see below a date field is formatted Month/Day/Year this is the display date according to Salesforce preferences. The Token Date is what comes from the Salesforce database and what will be displayed in PandaDoc.
Date & Time below is a reference to how those fields look coming out of Salesforce.
The Solution
To resolve this we can use Formula fields in Salesforce to format the dates & times to our liking. This can be fairly simple or more complex depending on what format you want and ill give several example formulas below.
To start pick the Saleforce date field you want to change. Mine is Date_Field__c
This is important as its going to be used throughout your formulas.
How to
Create a new field this can be on any object. I am using the opportunity.
Data Type will be "Formula"
Formula Return Type is "Text"
Text? but this is a date!!
If you were to use a date type here. Salesforce would convert this formula back into a date and save that data, in the same manner that it does your original value.
Text type ensures it will be displayed exactly as you save it.
The formula is going to vary based on the original date field name and the format you want the date to be displayed in.
MM/DD/YYYY
TEXT(MONTH(Date_FIeld__c))+"/"+TEXT(DAY(Date_FIeld__c))+"/"+TEXT(YEAR(Date_FIeld__c))
This formula uses my field named "Date_Field__c" and display the Date in MM/DD/YYYY.
if you would like DD/MM/YYYY you would change DAY and MONTH in the formula.
DD/MM/YYYY
TEXT(DAY(Date_FIeld__c))+"/"+TEXT(MONTH(Date_FIeld__c))+"/"+TEXT(YEAR(Date_FIeld__c))
Replace field name
Ensure you replace
Date_FIeld__c
with your field name.
Click through the remaining pages to save and display your new field. You do not need to add the new field to your page layout as it could confuse your users. Depending on which formula you used your new field should look like the "Formated Date" field below.
Add New Field as Token
When you create a new field in Saleforce that you want to use with PandaDoc you need to tell PandaDoc about that field.
To do this go the "PandaDoc Setup" tab in Salesforce.
Now click "Configure Objects"
Search for your new field. Be sure to take advantage of the search box and don't forget to click the save button.
Go back to your opportunity to check the token in the PandaDoc visualforce page.
Update PandaDoc Template
Now that your token is passing into PandaDoc it is important to update your Templates with the new field name.
Be sure to copy and paste the yellow [ ] values from salesforce into your templates. They are case sensitive. My new token is
[Formated_Date__c]
Updated about 1 year ago