Create a template file in the same file format as the output file format, either Excel (.xlsx, .xlsm), Word (.docx, .docm), or PowerPoint (.pptx, pptm). For PDF output, create a Word (.docx) format. The fields of the master object and related child objects can be used as the merge fields.
Master Object Merge Fields
Set the merge fields in the template file in the following format.
Merge Fields Format
{!Object Name.Field Name}
Example
{!Opportunity.Name} *Standard object.Standard field
{!Bill__c.IssueDate__c} *Custom object.Custom field
Child Object Merge Fields
For the merge fields of the child object, enter only one line. The number of lines is output according to the number of child records. If the reference field is a custom field, append "__r" at the end of the child relationship name.
Merge Field (2 levels)
Merge Fields Format
{!ChildObject Relationship Name.Filed Name}
Example
{!OpportunityLineItems.Name} *Standard field.Standard field
{!BillDetails__r.IssueDate__c} *Custom field.Custom field
How to check the child relationship name
- Go to the Object Manager and check the list of fields of the corresponding child object.
- Click on the field name of the primary object’s reference fields in the child object’s field list.
- The content displayed in the child relationship name in the field’s setting information is the child relationship name. At this time, if the parent object’s reference field is a custom field, the child relationship name will be the one with "__r" appended to the end of the displayed child relationship name. For package objects, prefix with namespace prefix + "__".
Sequential numbers
To output sequential numbers of child records, enter {!number()}. Sequential numbers starting from 1 is output.
Layout Options for Child Record (OFC Pro)
Layouts other than one record per line, such as Multi-line output per child record per record, are possible. The options are available in OFC Pro.
Option | Layout |
Output by Index Numbers of Child Record | ・Multi-line output per child record per record
・columnar output |
Block Output of Child Records (Excel) | Multi-line output per child record per record |
Group Output of Child Records (Excel) | Grouping by child record fields |
Package Object Merge Fields
For package objects, prefix with namespace prefix + “__”.
Master Object of Package Object Merge Fields
Merge Fields Format
{!Namespace Prefix__Object Name__c.Field Name}
Example
The package namespace prefix is "BillingMaster″ and the object name is "BM_Bills__c″.
{!BillingMaster__BM_Bills__c.Name}
Child Object of Package Object Merge Fields
Merge Fields Format
{!Namespace Prefix__Child Relationship Name__r.Field Name}
Example
The package namespace prefix is "BillingMaster″ and the child relationship name is "BM_BillDetail_Bills″.
{!BillingMaster__BM_BillDetail_Bills__r.Name}
Field Values
Data Type | Description |
Lookup/Master-Detail |
|
Date | Excel・・・Serial values are output.
Word/PowerPoint/PDF・・・The output is in the format on the Salesforce record screen. For formatting, refer to Formatting of Date and Date/Time Fields. |
Date/Time | Excel・・・Serial values are output.
Word/PowerPoint/PDF・・・The output is in the format on the Salesforce record screen. For formatting, refer to Formatting of Date and Date/Time Fields. |
Currency | Currency symbols are not output.
For formatting, refer to Formatting of Currency and Number Fields. For Ver.1, refer to Formatting of Currency and Number Fields (Ver.1). |
Number | For formatting, refer to Formatting of Currency and Number Fields.
For Ver.1, refer to Formatting of Currency and Number Fields (Ver.1). |
Rich Text Area |
|
Text (Encrypted) | The masked value will be the same as what is displayed to the user on the record detail page. |
Users who do not have permission to read the field
If the user who outputs files does not have reference permission to the merge field, the merge field will be output blank.
Decimal point Considerations
Some standard fields, such as Opportunity Amount and Quote Amount, may have decimal points stored in Salesforce even if the decimal point is not displayed on the record screen. For example, if Opportunity Quantity contains a decimal point, Amount is stored with a decimal point even though the data type of Amount is "Currency (16, 0)". The values stored in Salesforce should be checked in the Developer Console or Dataloader.
Office Features
Office features are not supported. Some Office features are available, but not all templates are supported. Complex patterns are not supported.
Available Office Features
File Type | Details |
Excel | Excel Formulas, Data Validation, Conditional Formatting, Table, and Shapes are available. |
Word | Table, Text Box, Watermark, Shapes and Field Codes are available. |
PowerPoint | Table, Text Box and Shapes are available. |
Table is available.
*Text Box, Watermark, Shapes and Field Codes are not available. |
*Tables are for layout only, excluding aggregate functions.
Notes on available Office features
- Not all templates are supported. Complex patterns are not supported.
- When opening the file, if the message "We found a problem with some content in 'XXX.xlsx'. Do you want us to try to recover as much as we can?" or other error messages, remove the Office features in the template.
- Office features are outside the scope of support. Check with your templates and output contents in the Sandbox.
Consideration・Limitations
- Not all layouts and output patterns are supported. Complex layouts are not supported.
- Formulas cannot be used such as {!If(xxxxx)} for the merge field.
- Template file size should not exceed 1 MB. If the file contains a large amount of text or images, even within 1 MB, the file will fail to output. The Office file consists of multiple XML files, compressed in a ZIP file, and the file size limit before compression is 4 MB.
- Template files should be created in the Microsoft Office desktop version. Template files created by other applications, such as online versions, are not supported.
- Office features are not supported. Some Office features are available, but not all templates are supported.
- Images such as company logos can be included in the template file. However, depending on the file size of the image, output may take a long time or result in an output error. In the case of PDF output, the layout may be corrupted. Please check the actual output in a test environment.
Reference
How to find the merge field and childrelation names
Troubleshooting
- Merge fields are not replaced by record values, but are output as they are.
- Rich text area field values are output with Html tags.
- The currency symbol for the currency field is not output.
- Number fields are not output with 3-digit comma delimiters.
- Extra decimal places are displayed for number fields.
- The merge field values are output in duplicate.
- The date "12/31/2024" for the filter condition results in an error.
- The borders of the table are not displayed.
- The graphs are not output correctly.
- Files cannot be downloaded continuously from the Custom button.
- Multiple files cannot be downloaded in batch output from the list view.
- "Insufficient Privileges / You do not have the level of access necessary to perform the operation you requested." is displayed.
- "You do not have access to the Apex class named 'OFCController'." is displayed.
- "The OFC_Template record with the Template API Name "XXX" does not exist. Please check if the Template API Name is correct." is displayed.
- "The template file size is too large or has too much content. Reduce the size or content of the template file. Apex heap size too large: XXX" is displayed.
- "The number of output child records exceeds the allowed value. If the output file contains Long Text Area or Rich Text Area fields, the maximum number of child records is approximately 100-200 records. The upper limit depends on the length of the data type. Aggregate query has too many rows for direct assignment" is displayed.
- ″Failed to read the template file. The file format may be incorrect or the file may be corrupt.″ is displayed.
- "List has no rows for assignment to SObject" is displayed when a guest user saves a file.