Merge fields

A merge field enables you to use a field name to incorporate a value from a record. For example, the merge field fHCM2__Hire_Date__c in a PDF Template used from a Team Member record produces the Team Member's hire date in the PDF document.

Merge fields in formulas

Merge fields in formulas use the API name of the field with no surrounding symbols:

Illustration: Field API name for fHCM2__Country_c field with the double underscores identified

Merge fields outside formulas

Merge fields used outside formulas require additional syntax:

Illustration: Merge fields outside formulas need to be surrounded by curly brackets and have an exclamation mark before the API name

Merge fields within an object

When using a merge field to reference a field in the same object, you can use full Salesforce syntax with the object API name as a prefix to the field API name:

Illustration: You can preface a field API name with the object API name

Or you can leave out the object API name and just use the field API name:

Illustration: Field API name without the object API name

Merge fields across objects

Merge fields can work across objects, enabling you to generate a document such as an email or PDF file from one object referencing a field or fields in another object or objects.

Cross-object referencing uses an extension of Salesforce syntax to greatly enhance the range of merge fields you can reference in Sage People.

Follow these rules:

  • The merge field must start from the current object. For example, if you are sending a document from Team Member, the first reference must be to a field in Team Member.

  • Objects contain Lookup fields to provide links to other objects. For example, Team Member includes the following lookup fields:

    Field API Name Links to
    Current Competency Assessment fHCM2__Current_Competency_Assessment__c The most recent, completed, competency assessment for the Team Member.
    Current Employment fHCM2__Current_Employment__c The most recent Employment Record for the Team Member.
    Current Job Description fHCM2__Current_Job_Description__c The most recent, completed, job description for the Team Member.
    Current Performance Review fHCM2__Current_Performance_Review__c The most recent, completed, performance review for the Team Member.
    Current Talent Plan fHCM2__Current_Talent_Plan__c The most recent, completed, talent plan for the Team Member.
    Department fHCM2__Department__c The Team Member's HR Department.
    Job Profile fHCM2__Job_Profile__c The Team Member's job profile.
    Policy fHCM2__Policy__c The policy assigned to the Team Member.

    Use the Lookup fields in the current object when building merge field references across objects.

For more examples see Selected reference fields.

Note

Test cross-object merge fields carefully in your email templates. Cross-object fields work in emails triggered by action events but not in emails sent from Salesforce Flows. If you need a cross-object merge field in an email template for a Flow, create a formula field on the object where the email is triggered. For more information about formula fields, see Formulas | Create a formula field.

Dates in merge fields

By default, dates used in merge fields display using the locale settings defined for your org. If you want to display dates in a different format, you can include date formatting in the merge field. For example:

  • To display the month of the employment start date as a three letter abbreviation:

    Copy
    {!dateformat(fHCM2__Employment__c.fHCM2__Start_Date_c, 'dd MMM yyyy')}
  • To display the full month name of the employment start date at the start of the date format:

    Copy
    {!dateformat(fHCM2__Employment__c.fHCM2__Start_Date_c, 'MMMM dd, yyyy')}
  • To display the three letter abbreviation of the weekday name for an absence start date:

    Copy
    {!dateformat(fHCM2__Absence__c.fHCM2__Start_Date_c, 'EEE dd MMMM yyyy')}

Some date fields do not allow you to apply date formatting when used as merge fields:

  • Interview date on the Application object

    fRecruit__Application__c.fRecruit__Interview_Date__c

When date formatting is not applied, these fields display dates correctly when used as merge fields. If you are attempting to apply date formatting to one of these fields:

  1. Create a custom formula field with the formula return type Text.

    Use the Advanced Formula editor to enter the formula.

  2. Add the formula field as the merge field.

Note

Date/Time fields are stored in GMT using the format yyyy-mm-ddThh:mm:ss.000Z, for example: 2023-11-03T18:20:54.000Z.

When applying a formula to a text field holding a Date/Time you can extract the parts of the date and time you need to display. Add the text string GMT to make the timezone clear.

For example:

MID(TEXT( End_Date__c ), 9, 2)&"-"& MID(TEXT( End_Date__c ), 6, 3)&"-"&LEFT( TEXT( End_Date__c ) , 4)&" GMT"

displays 2023-11-03T18:20:54.000Z as 03-11-2023 GMT

Number and currency in merge fields

For formatting number or currency fields, review the options used in the settings of the field itself. The field settings enable you to set the number of decimal places, for example.

No equivalent option to dateformat exists for number or currency fields when used as merge fields. If you need merge fields to format number or currency fields differently from their format elsewhere, consider creating a formula field with the desired formatting, and use it as the merge field.

BLANKVALUE() and adding substitute text

When you use the BLANKVALUE() function with a merge field, you can add substitute text to a merge field. Substitute text displays in the generated document (email or PDF for example) if the merge record does not contain data in that field. For example:

Please attend your Back to Work interview on {!BLANKVALUE(fHCM2__Absence__c.fHCM2__Back_To_Work_Interview_Date__c, the date to be advised by your HR Contact)}.

This merge field displays the Back To Work Interview Date when it has been set, and the substitute text "...the date to be advised by your HR Contact" when the date has not been set.

Tip

In email templates you can omit the BLANKVALUE() function, but you must include it in PDF templates for substitute text to work correctly.