S-Docs provides many advanced features for merging data into your S-Doc Template. In most cases described in this manual, they require editing of the template source code, which can be easily accessed by clicking on the "Source" button on the S-Docs Template Editor page.

The template source is based on HTML with specific tags that indicate the S-Docs engine will apply specific mergers or functions.

Merged Fields Functions

You can apply multiple functions to merged field data by adding a space and a specific syntax (function) to the end of the field name.  For example, {{!opportunity.amount}} will return an unformatted numeric value as it is stored in the Salesforce database; adding {{!opportunity.amount #,###.##}} will return the same value, but formatted to include commas and two decimal places. Please take note of the following:

  • All functions require a space between the merge field name and the function.
  • When using merged fields within other tags, you may need to escape the HTML in order for the merge to happen properly.
  • Be careful when using the Graphical UI editor to change the appearance of the merged field tag. Care must be taken that styling changes do not interject the merged field syntax. Eg {{!Opportunity.<style= You may need to click on "source" to validate merged fields do not contain any characters

 

Function NameUsage & ExamplesNotes
Format NumberFormat number function provides formatting numbers without having to create formula fields.Only the following EXACT patterns/values are supported for a number format:

#,###.##  (Typical Currency with cents)

#,###     (Comma delimited whole number)

#.###     (EU formatting)

#.###,##

 

{{!Opportunity.amount #,###.##}}

43222300.8 à 4,222,300.80

{{!Opportunity.amount #,###}}

43222300.8 à 4,222,301

{{!Opportunity.amount #.###}}

43222300.8 à 4.222.301

Larger numbers will still follow the pattern even if they exceed the 4 digits shown in the pattern.Rounding is applied when precision exceeds formatting.

If you need to include a currency symbol, you can add it just before the merged field. Eg ${{!Opportunity.amount #.###}}

 

Format DateFormat date allows salesforce date and datetime fields to be formatted into any valid java pattern.

{{!opportunity.createdDate MM/dd/yyyy}}

2018-10-28à 04/04/2017

{{!opportunity.createdDate MMMMM}}

2018-10-28à October

Patterns are case sensitive. eg MM=month while mm=minutes.Reference to available patterns.

 

Times are formatted per the database time (GMT).

Long descriptions (eg Month, day of week) are in English. You can use formula fields if needed to meet a specific requirement.

Check FontsMICR E-13B font(Magnetic Ink Character Recognition) is used for banking and more specifically for generating checks.

{{!Check__c.RoutingNumber__c MICR11}}

1234567890toadà

To adjust spacing between MICR characters:

{{!Opportunity.Description MICR[FONTSIZE (REQUIRED)],[SPACING (OPTIONAL)]}}
e.g.
{{!Opportunity.Description MICR20}}
{{!Opportunity.Description MICR20,-5}}

{{!Opportunity.Description MICR20,5}}

 

 

The output is a series of images that can be used in PDF generation of checks.Only digits and ‘t’,’o’,’a’,’d’ are transformed. Other characters are ignored.

The number following MICR represents the font width. eg MICR16 will be larger than MICR8.

 

Spacing defaults to 0 if it is not specified. As shown, negative spacing values are allowed. The lower the spacing value, the closer together MICR characters.

CapitalizeTransforms data to all uppercase characters.

{{!contact.billingStreet ToUpperCase}}

123 Main Street, Apt 3 à 123 MAIN ST, APT 3

Right to Left (RTL)Reverses the character string in the output. This is useful for RTL languages like Hebrew when generating to a PDF.{{!account.greeting__c RTL}}

שלוםà םולש

 

 

 

This feature is for transforming merged field data only.To apply rtl within the template content, use the Styles picklist in the toolbar to apply right-to-left to appropriate sections of your template.

The following style can be applied within source mode as well.

<span dir="rtl">reverse</span>

 

TranslateUses Salesforce Translation Workbench feature to return the picklist value based on the users locale/language settings{{!product2.color translate}}

BLUE à BLEU

This feature leverages salesforce toLabel() function within a SOQL query. It is particularly useful for orgs that have Translation Workbench enabled.Translate keyword will cause an error if used on field types that do not support toLabel().

Translate can be used only on fields

For related list translations, or lookup fields, you should use direct SOQL query. If you set the class to "none" then only the data is returned – not in a table format.  Here is an example usage from the S-Docs template source:

<!--{{!

<LineItemsSOQL>

<class>none</none>

<soql>Select tolabel(color__c) From product2 where id='{!ObjectID15}' and toLabel(color__c) =’BLEU’</soql>

<column>color__c</column>

</LineItemsSOQL>

}}-->

Additionally, for fields merged within related lists, you may find the substitute column attribute feature useful.

 

By default, S-Docs merges related lists into your template in the form of a table, where each record returned is generated as a row in the table. This means the table grows linearly with the number of records returned. In order to meet more specific formatting requirements, S-Docs has a variety of advanced attributes that can be leveraged.

Feature NameDescription
DirectSOQLAllows you to execute a custom SOQL query within your template and merge the resulting data into your document at runtime. DirectSOQL supports aggregates and subquery functions.
RenderProvides ability to show/hide sections of a template based on a condition.

Displaying Related Lists & SOQL Line Items Without Table Formatting

To remove the table formatting in a related list or SOQL table, you can place <class>none</class> at the beginning of your related list / SOQL code. For example, the following code will display account team members as a comma-delimited list rather than as a table:

<!--<lineitemsSOQL>
<prefix>The Account Team Members are: </prefix>
<class>none</class>
<soql>
SELECT user.name FROM accountteammember WHERE accountid='{!account.id}'
</soql>
<column postfix=", ">user.name</column>
<postfix>. Please see page 3 for their contact information.</postfix>
</lineitemsSOQL>-->

In this example, <class>none</class> removes all the table formatting. The prefix attribute adds a comma and a space between each account team member, but we did not have this prefix attribute here, the items returned by the SOQL query might look something like this: Jack JohnsonJohn JacksonSarah McCleanJohn Paulson. This is because using <class>none</class> will make your SOQL query or related list return raw data with no spaces or table formatting, all on the same line.

Related List Column Attributes

Related lists contain columns that can optionally include additional attributes (shown in bold below). These attributes provide a powerful way to dynamically manipulate data to meet your requirements.

Note: Attributes must always be double quoted, e.g. format-date="MM/dd/yyy".

Example: <column format-date="MM/dd/yyyy">createddate</column>

Column AttributeValuesDescription & UsageSyntax Example and notes
substituteComma delimited list of key-value pairs.Allows for replacing values with other values whenever a match is made.It checks the value against a series of values. If it is equal to a value, it returns the corresponding  result. If it does not match, no substitution is made unless a final catch-all value is provided in the list.

 

Substitute functionality can be useful for translating values to different languages for a template. While you may be able to do the same using a salesforce formula field, this can drastically reduce the number of formula fields would need to create.

 

<column substitute=" value1tomatch, value1ToSubstitute, value2ToMatch,Value2ToSubstitute,

…,

OptionalCatchall-substitution">Field__c

</column>

 

If the substitute list contains an odd number of values, then the last value will be the catch-all that is substituted when no matches are made

·   Substitute a checkbox for german language values:substitute="true,Ja,false,nien"

·   Matches are made ignoring case sensitivity and whitespaces are trimmed, but the substitute values are exact.

·   For checkbox fields use true and false as the value to match on

·   For organization purposes you can optionally use parenthesis to organize your list eg:

substitute= " (1,one),(2,two),(3,three)"

·   If your value is null, you should not use the substitute attribute but rather use the  nullprefix= attribute that will allow you to insert a value whenever null data is encountered for that field.

·   If you are matching a numeric value, the precision needs to also match

<column substitute "2.00,2">quantity</column>

·   Example:  Use Substitute feature to correctly display the full month Name of field that contains the month number:

<column substitute="1, Januar,
2, Februar,
3, März,
4, April,
5, Mai,
6, Juni,
7, Juli,
8, August,
9, September,
10,Oktober,
11,November,
12,December,
unknown">MonthNumber__c</column>

type"rtf" or "checkbox"If your field contains markup that you wish to preserve and display in your document, you can specify type="rtf".This is useful for inserting blocks of information that already contains formatting/markup.

 

If you want to display the a checkbox image (checked and unchecked) rather than the database values of true/flase or yes/no, you can use type ="checkbox"

 

<style type="rtf">Your content goes here.

</style>

When using type ="checkbox" the checkbox images have a class called "sdcheckbox". If needed you can modify the css treatment of the checkbox. Eg

<style type="text/css">

.sdcheckbox {

width: 10px;

height: 10px;

border: 1px solid #73AD21;

}

</style>

 

headerStringAllows you to specify a header text.<column header="YourHeaderHere">Example: <column header="Grand Total">will place "Grand Total" over that column as a header
format-numberNumberAllows you to format your column’s numbers to automatically include commas and periods.<columnformat-number="#,###.##">

 

 

Format number supports these four types:#,###

#,###.##

#.###

#.###,##

For example, if a number in your column was stored as 123456 and you chose the 2nd type listed above, the number would appear as 1,234.56

format-dateDate, Date/TimeFormat date allows salesforce date and datetime fields to be formatted into any valid java pattern.{{!opportunity.createdDateMM/dd/yyyy}}

2018-10-28à 04/04/2017

 

To display just the month, you can use:{{!opportunity.createdDate

MMMMM}}

2018-10-28à October

To turn a date into just a day or a month, you can do the same, but with D’s or Y’s instead of M’s.

mergenextAny valuemergenext="true", merges this cell with the cell to the right of it.<column mergenext="true">If you have a currency symbol column and an amount column, like$        |        12

$        |        4

you can merge these two columns together and the resulting column will be

$12

$4

Prefix and postfix are useful to put any spacing between cell values.

Note: mergenext is not supported when using group-by functionality

colspanAny valueAllows you to create a column that spans across multiple columns.<columncolspan="4"><column
colspan="1">
has no effect; by default, a column already spans 1 column.
<column
colspan="4">
will make this column span 4 columns total (i.e. this column will be 3 columns longer than it would normally be).
This works the same as the HTML colspan attribute.
newrowAny valueAllows you to specify when to end the current row and create a new one.<column newrow ="4"><column newrow="true">
will create a new row for each record in this column. For example, instead of seeingcell 1 | cell 2 | cell 3,you will seecell 1
cell 2
cell 3----<column newrow="3">
will create a new row after the 3rd record of each row, e.g.cell 1 | cell 2 | cell 3
cell 4 | cell 5 | cell 6
cell 7 | cell 8 | cell 9This attribute is useful for creating documents such as mailing labels.
prefixAny valueAllows you to put a string at the beginning of each column.<columnprefix="YourStringHere"><column prefix="$"> would put a dollar sign at the beginning of each column like so:$                12

$                4

nullprefixAny valueIf the content of a column is "null", this will swap null with a string or character of your choice at the beginning of your column.<columnnullprefix="YourStringHere"><column nullprefix="N/A"> will make columns with "null" values appear as N/A
postfixAny valueAllows you to put a string at the end of each column.<columnpostfix="YourStringHere"><column postfix="dollars"> would put "dollars" at the end of each column like so:12                dollars

4                  dollars

nullpostfixAny valueIf the content of a column is "null", this will swap null with a string or character of your choice at the end of your column.<columnnullpostfix="YourStringHere"><column nullprefix="N/A"> will make columns with "null" values appear as N/A