Category

Developer’s Guide

Preview Documents Within the Template Editor

By Developer's Guide, Documentation No Comments

In This Article:

  1. Enabling Template Previews

As you build an S-Docs template, you'll likely want to generate a document using that template several times in order to see how each change you make appears in an actual generated document. You can streamline this process by using the Template Preview feature.

Enabling Template Previews

To use this feature, navigate to the Advanced Options tab of the template editor and find the Preview Settings section. This section has a single field titled Preview ID. When you fill in the Preview ID field with the ID of a test record, a button titled Save & Preview will appear at the top of this page.

Record IDs can be found in the URL when you're viewing the record.

You can click the Save & Preview button in the template editor to generate and view a test document for the Account record with the ID you provided.

When you click "Save & Preview", a new tab will open in which a document is generated and automatically opened for previewing. This saves you even more time throughout your template development process.


Limitations of the S-Docs Rendering Service

By Developer's Guide, Documentation No Comments

General limitations of S-Docs Capabilities:

  • S-Docs runs on the Salesforce Platform and is bound by all Execution Governors and Limits placed on the Salesforce platform. These limits have been known to change with each Salesforce release and can have a wide impact on S-Docs that results in errors when generating and viewing S-Docs. Those errors can appear if the generated document:
    • Is too many pages long, too large in terms of file size, too complex in terms of logic within a template, takes an extended amount of server time to generate, requires too many database queries, database queries take too long to execute and a wide variety of other causes.
  • S-Docs typically supports up to 50-100 documents in mass merge documents. The upper limit is driven by Salesforce governor limits and is dependent on your template's complexity.
  • Salesforce Execution Governors also affect emails, notifications, and processes that S-Docs may run. Please visit this link for a complete and updated list of Salesforce Governor Limits.
  • S-Docs emails are subject to the following Salesforce email limitations.
  • Javascript and Dynamic CSS is not supported.

PDF Output:

When using the S-Docs rendering service for PDF output, please be aware of the following additional considerations and limitations:

  • The PDF rendering service renders PDF version 1.4
  • Fillable PDFs are not supported
  • Password-protected PDFs are not supported
  • The rendered PDF file either displays in the browser or is downloaded, depending on the browser’s settings. Specific behavior depends on the browser, version, and user settings, and is outside the control of S-Docs
  • If images outside of Salesforce are used in the S-Docs template directly, or dynamically through a merged image field, you must whitelist the URL domain (using Setup > Remote Site Settings) to avoid broken image icons in the PDF
  • The final document will render the markup and data, but it might not render formatting contained within the contents of rich text area fields, or image fields added to the template unless you specify them as containing markup
  • Long lines of text that don’t have break points, such as a space or dash, can’t be wrapped by the PDF rendering service. This most commonly happens with very long URLs and multibyte character strings. When these lines are wider than the page, they increase the width of the page’s content beyond the edge of the PDF page. This causes content to “flow” off the side of the page, cutting it off
  • PDF templates support CSS 2.1. Some CSS attributes, such as word-wrap, are CSS 3, and are therefore not supported
  • PDF rendering doesn’t support JavaScript-rendered content
  • Fonts supported (specified as font-family): Arial Unicode MS, sans-serif, serif, courier. Web fonts and other fonts are not supported. S-Docs provides additional support for MICR fonts.
  • Bold, italicized, or underlined text is not supported in PDF files that use Unicode fonts (if you have selected template contains international characters)
  • If the PDF file fails to display all of the page’s text, particularly multibyte characters such as Japanese or accented international characters, make sure you check off Template contains international characters in the “Document Options” tab of the template editor. If merged field values are failing to render correctly, also set the “Unicode enforcement level” to Strict to override any font settings that are being applied to merged fields.
  • “Arial Unicode MS” is the only font supported for extended character sets that include multibyte characters
  • The maximum response size when creating a PDF file must be less than 15 MB
  • The maximum file size for a generated PDF file is 60 MB
  • The maximum total size of all images included in a generated PDF is 30 MB
  • PDF rendering doesn’t support images encoded in the data:URI scheme format

PDF-Upload:

Note: Limitations to PDF files in general also apply to the PDF-Upload feature in addition to the limitations listed here.
  • PDF is the only file type supported
  • Pre-existing templates cannot be switched to the PFD-Upload template format
  • PDF-Upload templates cannot be switched to a different template format
  • The Header, Footer, Page Settings, and Auto Create Task tabs are not available
  • PDFs must be the traditional 8.5 x 11 inch size; landscape PDFs are not supported
  • The page count upper limit is currently around 15 pages. Keep in mind that certain contents increase template size and complexity (such as images or large amounts of text), which may have an effect on the page number limitation
  • To export templates and transfer them between orgs, use the S-Docs Template Migrator instead of manually exporting and importing the template data.
  • Component templates are not supported
  • Related Lists are not supported
  • Render statements need to be written out (the Insert RENDER button is not supported)
  • Nested renders are not supported
  • Named queries are not supported
  • SOQL queries are not supported

DOCX & PPTX Output:

Upper Limits

These limits are upper limits only; depending on the complexity of your document, you may run into limits on the file size or processing time well below these limits. Nonetheless, we estimate that at least 80% of DOCX/PPTX templates should be able to reach these upper limits. For DOCX templates that exceed these limits, other formats such as DOC can be used to fulfill your use case.

  • Your uploaded template has an upper limit of 10 related lists
  • Your uploaded template has an upper limit of 10 pages for DOCX and 10 slides for PPTX. Generated documents have an upper limit of 20 pages for DOCX and 20 slides for PPTX

What DOCX/PPTX supports without limitations:

  • Merge fields and merge field formatting like format-date, format-number, etc.
  • RENDER feature
  • Salesforce Lightning
  • Salesforce Console
  • Embedding images referenced via URL (e.g. images from rich text fields, or <img src=...>) into the DOCX/PPTX for documents generated on SDCreate3
  • Named queries
  • One-click and zero-click buttons
  • Email

What DOCX/PPTX supports, with limitations:

  • S-Doc Jobs
    • Documents generated via S-Docs Jobs must have a final size of less than ~120 KB
  • Mass merge batch document generation
    • For DOCX/PPTX templates less than ~120KB (same as the limitation on S-Doc Jobs)
  • Mass merge combine-all into single printable DOCX
    • Each document in a single printable DOCX/PPTX has a limitation of 120KB because those documents are generated by S-Docs Job. See the above limit
  • Embedding images referenced via URL (e.g. images from rich text fields, or <img src=...>) into the DOCX/PPTX for documents generated via SDBatch or S-Doc Jobs
    • Rich text image fields are fully supported if the document isn't generated using an S-Docs Job (via an S-Docs button). If they are generated via S-Doc Job, the ~120KB limit still applies per document
  • Runtime prompts
    • If your runtime prompt merge field result has rich text formatting, like bold red text, it won't show up in the final template
  • Related lists
    • Simpler related lists are supported, but more complex related list qualities like using <td> cells as column prefixes are currently not supported
  • Rich Text Fields
    • Line breaks, images, and ordered/unordered lists are retained. Note that if a list begins on line 1 of the rich text field, a blank line will be inserted above it. All other formatting (such as bold text and alignment) is removed
    • Fonts and font sizes will not be pulled from Salesforce rich text fields into your DOCX document - they will simply match Microsoft Word's "Normal" style. If you want your document to display the font from your rich text field, you can either change Microsoft Word's "Normal" style to match the desired font/font size, or use the font-family and font-size merge field attributes

What DOCX/PPTX does not support:

  • Generating DOCX/PPTX without creating an Attachment or File
  • The Live Edit feature
  • "Related To Type" of OpportunityLineItem, QuoteLineItem, or any other standard Salesforce object that does not support Notes & Attachments
    • We recommend using DOC for these objects
  • Percentages as units of measurement in images
    • However, absolute sizes (i.e. inches, centimeters, pixels) are fully supported

XLS/XLSX Output

  • DOCX & PPTX limitations also apply to XLS/XLSX output.
  • XLS supports related lists, but not multiple sheets
  • Related lists are not currently supported for the output type XLSX
  • Size limitation: For very large, text-dense XLSX templates, you may hit a file size limitation.


Special Merge Fields in S-Docs

By Developer's Guide, Documentation No Comments

Introduction

Suppose you’re developing an S-Doc template for a contact. Including merge fields for a contact’s name or phone number is pretty straightforward. However, what if you want to include data outside the scope of the contact object, such as the date the document itself was generated? Or, perhaps you find that {{!Contact.Id}} displays an 18-character ID when you’d really like to display a 15-character ID. No problem! To provide you with an increased range of easy-to-use templated data, S-Docs includes a special set of merge fields, shown in the following table.

Special Merge Fields

Merge Field Rendered Text in Output Document
{{!DocumentID}} S-Doc ID of the document you generated (e.g. SD-174; this is not a Salesforce ID).
{{!DocumentName}} Name stored in the “Template Name” field on your
S-Doc template record detail page.
{{!DocumentObject}} Type of Salesforce object that this document was generated for.
{{!DocumentDate}} Date that this document was generated. (See Formatting Dates for information on formatting dates in merge fields).
{{!DocumentDateSOW}} Start of week date for the document that was just generated.
{{!DocumentDateEOW}} End of week date for the document that was just generated.
{{!DocumentDateTime}} Date and time that this document was generated.
{{!DocumentFormat}} Filetype of this document (PDF, DOC, etc.).
{{!ObjectId18}} 18-character ID of the Salesforce record this document was generated for.
{{!ObjectId15}} 15-character ID of the Salesforce record this document was generated for.
{{!UserFirstName}} First name of the user who generated this document.
{{!UserLastName}} Last name of the user who generated this document.
{{!UserName}} Full name of the user who generated this document.
{{!UserOrganizationName}} Organization name of the user who generated this document.
{{!UserLoginName}} Salesforce username of the user who generated this document.
{{!UserEmail}} Email address of the user who generated this document.
{{{!UserSignature}}} Salesforce email signature of the user who generated this document.


Advanced Template Features

By Developer's Guide, Documentation No Comments

Introduction

S-Docs provides many advanced features for merging data into your S-Doc Template. In most cases described in this document, 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.

Merge Fields Functions

You can apply multiple functions to merge 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 merge 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 merge field tag. Care must be taken that styling changes do not interject the merged field syntax. E.g. {{!Opportunity.<style= You may need to click on Source to validate that merged fields do not contain any characters.
Function Name Usage & Examples Notes
Format Number

Format 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. E.g . ${{!Opportunity.amount #.###}}

Format Date

Format 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

{{!opportunity.datetime__c MM/dd/yy hh:mm:ss TZ:America/New_York}}

2018-10-28 ➤ 10/28/2018 12:56:32 EST

  • Patterns are case sensitive. E.g. MM=month while mm=minutes. Reference to available patterns.
  • Times are formatted per the database time (GMT).
  • Time zones must be written using Java time codes.
  • Only Salesforce-supported time zones are accepted.
  • Long descriptions (e.g. Month, day of week) are in English. You can use formula fields if needed to meet a specific requirement.
Display Checkboxes

The checkbox attribute allows you to map checked/unchecked checkbox images to boolean fields.

{{!opportunity.checkbox__c checkbox="true"}}

Displays a checkbox with a dotted white border; includes a black checkmark if checked.

{{!opportunity.checkbox__c checkbox="black"}}

Displays a checkbox with a solid black border; fills in with black and includes a white checkmark if checked.

{{!opportunity.checkbox__c checkbox="radio"}}

Displays a radio button.

  • When this attribute is added, the merge field will display as the checkbox in its current state on the record once the document is generated.
Check Fonts

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

{{!Check__c.RoutingNumber__c MICR="11"}}

To adjust spacing between MICR characters:

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

{{!Opportunity.Description MICR="20,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. E.g.  MICR="16" will be larger than MICR="8".
  • 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.
Capitalize

Transforms data to all uppercase characters.

{{!contact.billingStreet ToUpperCase="true"}}

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

Lowercase

Transforms data to all lowercase characters.

{{!contact.billingStreet ToLowerCase="true"}}

123 MAIN ST, APT 3 ➤ 123 Main Street, 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="true"}}

שלום➤ םולש

 

 

  • Using the RTL merge field attribute will transform merge field data only, not static text.
  • To apply RTL for both merge fields and static text,  use the following style in the template source:

<rtl>reverse</rtl>

  • When using <rtl> tags, there is no need to add the RTL attribute to your  merge fields. You can wrap an entire template in <rtl> tags to transform both merge field data and static text.
  • Note that <rtl> tags will not work properly with text that breaks across two lines in the generated document. You should use separate <rtl> tags for each line if text breaks across two lines.

 

Translate

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

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 and field labels.

  • 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</class>
<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.
Display Picklist Field Values Instead of API Names

The Display attribute will render picklist field values as the field value (the value shown to users on records). By default, S-Docs renders the field value API name.

{{!Opportunity.PicklistField__c Display="true"}}

  • In most cases, picklist field values are identical to their API names. This attribute covers instances when the two differ.
Create New Lines for Multi-Select Picklist Values

The msnl attribute will replace the semicolons between values from a multi-select picklist with new lines.

{{!Opportunity.Multi_Select_Picklist_Field__c msnl="true"}}

Insert Line Breaks After A Specified Character Count

The breakeverynchars attribute will insert a line break after the character number that you specify

{{!Opportunity.Long_Field__c breakeverynchars="10"}}

This Is A Long Field Of Text ➤ This Is A
Long Field
Of Text

  • Negative, zero, or blank values will not insert any line breaks.

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 Name Description
DirectSOQL Allows 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.
Render Provides 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:

[code lang="html"]<!--<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>-->[/code]

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 if 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.

Alternatively, if you need to format your related list data in an entirely new way, you can also generate a template component that formats your data and then merges it into your final document. Click here to read more about this feature.

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/yyyy"
Example: <column format-date="MM/dd/yyyy">createddate</column>
Column Attribute Values Description & Usage Syntax  Example and notes
substitute Comma 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 you 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 white spaces 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, e.g.:

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>

replaceall Comma-delimited list of key-value pairs.

Allows for replacing values with other values. This is very similar to the substitute feature, with the following two exceptions:

1) substitute matches against (and replaces) the ENTIRE string, where as replaceall matches against (and replaces) all substring appearances of the specified string.   

2) There is no "else" condition in replaceall (since we're replacing substrings, an "else" condition would be nonsensical)

This attribute supports regexs.

<column replaceall="replaceThis1,replaceWithThis1,replaceThis2,replaceWithThis2,...replaceThisN,replaceWithThisN">

Regex Syntax: start your replaceall string      with [regex] (including brackets)

For example, say you want to replace all        "a) This is a test", "b) This is a test", etc. with " a) This is a test", " b) This is a test" but NOT replace anything that looks like "1. This is a    test", "2. This is a test", etc. (i.e. you want to       indent a) b) c) but not 1. 2. 3. and the data   structure / related list formatting prohibit     simpler solutions like using <li></li>). To    achieve this, you could use the following:       <column replaceall="[regex]([a-zA-Z]\)),     &nbsp;&nbsp;&nbsp;&nbsp;$1">

  • If the data value is "Burlington
    Textiles Corp," but you want it to be "Boston Textiles Corp," use <column replaceall="Burlington,Boston">
showcolumn Conditional statement Allows you to conditionally hide a column.

<column showcolumn="{{!Object.Fieldname}} == 'FieldValueThatTriggersColumnHiding'">...</column>

Note that the column will be hidden if the syntax resolves to true.

If your table has a header row, you will need to apply the same condition to the header row as a RENDER statement:

<!--RENDER='{{!Object.Fieldname}}' == 'FieldValueThatTriggersColumnHiding'--><th>Column Name</th><!--ENDRENDER-->

  • You can conditionally hide an entire column in your related list if the Opportunity record's StageName
    field has a value of 'Prospecting' or 'Closed' by using the following: <column showcolumn="{{!Opportunity.StageName}} == 'Prospecting'|| {{!Opportunity.StageName}} == 'Closed'">...</column>
type "rtf", "checkbox", or "radio"

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 a checkbox or radio button image (checked and unchecked) rather than the database values of true/false or yes/no, you can use type ="checkbox" or ="radio"

 

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

</column>

  • When using type ="checkbox" the checkbox images have a class called "sdcheckbox." If needed, you can modify the CSS treatment of the checkbox. E.g.

<style type="text/css">
.sdcheckbox {
width: 10px;
height: 10px;
border: 1px solid #73AD21;
}
</style>

 

header String. Allows 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-number Number. Allows you to format your column’s numbers to automatically include commas and periods.

<column format-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-date Date, Date/Time. Format date allows Salesforce date and datetime fields to be formatted into any valid java pattern.

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

  • To turn a date into just a day, month, or
    a year, you can use <column format-date="MMMMM"> (for days, use D, and for years, use Y)
mergenext Any value. Allows you to merge a 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.

colspan Any value. Allows you to create a column that spans across multiple columns. <column colspan="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.
newrow Any value. Allows 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 seeing
cell 1 | cell 2 | cell 3
you will see
cell 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 9
This attribute is useful for creating documents such as mailing labels.
prefix Any value. Allows you to put a string at the beginning of each column. <column prefix="YourStringHere">

<column prefix="$"> would put a
dollar sign at the beginning of each
column like so:$                12

                            $                4

nullprefix Any value. If 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. <column nullprefix="YourStringHere"> <column nullprefix="N/A"> will make columns with "null" values appear as
N/A.
postfix Any value. Allows you to put a string at the end of each column. <column postfix="YourStringHere">

<column postfix="dollars"> would put "dollars" at the end of each column like so:12                dollars

4                  dollars

nullpostfix Any value. If 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. <column nullpostfix="YourStringHere"> <column nullprefix="N/A"> will make columns with "null" values appear as
N/A.
allprefix Any value. This replaces the need to use both prefix and nullprefix in the same template if they have equal values. If your template has both prefix and nullprefix set to the same value, you can replace them with this attribute. <column allprefix="YourStringHere"> <column allprefix="$"> will put "$" at
the beginning of each column
regardless of if the value is null or not.
allpostfix Any value. This replaces the need to use both postfix and nullpostfix in the same template if they have equal values. If your template has both postfix and nullpostfix set to the same value, you can replace them with this attribute. <column allpostfix="YourStringHere"> <column allpostfix="€"> will put "€"
at the end of each column regardless
of if the value is null or not.
abfprefixouter Any value. Allows you to put a string at the beginning of each column except the first one. The string will appear on the outside of the prefix attribute's contents. <column abfprefixouter=","> <!--{{!
<lineitemsSOQL>
<class>none</class>
<soql>SELECT productcode FROM opportunitylineitem WHERE Opportunityid ='0061U0000078tEw'
</soql>
<column abfprefixouter=", ">productcode</column>
<postfix>.</postfix>
</lineitemsSOQL>
}}-->This example would create a list of products that looks like:product1, product2, product3.
startIndex Any numerical value. Allows you to offset the beginning row number when you include the rownum column in your related list. <column startIndex="3"> Note that numbering starts at the number equal to the startIndex number + 1.

 

<lineitems>
<class>table646</class>
<listname>opportunitylineitems</listname>
<column startIndex="3">rownum</column>
<column>PricebookEntry.Product2.name</column>
<column>PricebookEntry.Product2.description</column>
<column>unitprice</column>
<column>quantity</column>
<column>totalprice</column>
</lineitems>
}}-->

This example would output a table with row numbers beginning at 4.

render Comma-delimited list of render conditions & output values. Allows you to conditionally render different values in your related list columns. <column render="CONDITION_1,output_value_1,CONDITION_2,output_value_2...DEFAULT OUTPUT VALUE IF ALL RENDERS EVALUATE TO FALSE"> Notes:

  • This feature is only supported with <lineitemsSOQL> statements
  • You must use <soql>...</soql> tags and include any field specifed in your subsitute="..." attributes in your SOQL query
  • You should not specify a field between the <column></column> tags. Doing this may cause issues
  • You can use RECORD.Field_Name to use related list record data fields within the render="..." attribute

Examples:

<column render="RECORD.Product_Type__c STARTSWITH Vacuum && RECORD.Product_Type__c ENDSWITH Cleaner,RECORD.Vacuum_Name__c,Not a Vacuum"></column>

  • If the Product's Type field starts with Vacuum and ends with Cleaner, the column will output the name of the vacuum, otherwise the column will output "Not a Vacuum."

<column render="RECORD.Title==null,No Title Available,RECORD.Title"></column>

  • If the Contact's title field is blank, the column will output "No Title Available," otherwise it will output the Contact's title.

You can also use nested render statements:

<column render="RECORD.Country__c == usa,[RENDER1]RECORD.City__c == new york,S-Docs HQ,[RENDER2]RECORD.City__c == ann arbor,S-Docs Innovation Center,[ENDRENDER2][ENDRENDER1],Work From Home"></column>

  • If the record's Country field is USA, and the city is New York, the column will output "S-Docs HQ." If the record's Country field is USA and the city is Ann Arbor, the column will output "S-Docs Innovation Center." If the record's Country field is not USA, the column will output "Work From Home."

<column type="rtf" render="RECORD.StageName == 'Closed',<span style='font-color:red;'>Closed</span>,Open"></column>

  • If the Opportunity is Closed, the column will output "Closed" in red. Otherwise, the column will output "Open" in the default font color.
breakeverynchars Any numerical value. Inserts a line break after a specified character amount. <column breakeverynchars="10">

<column breakeverychars="10">Long_Line__c</column> will insert a line break after every 10 characters.


Adding a Related List to Your Template

By Developer's Guide, Documentation No Comments

Introduction

It's often necessary to include data from a record's related lists in your documents. In the template editor, S-Docs includes a powerful, easy-to-use related list generator just for this purpose.

For example, if you have a template from an opportunity, you can insert a related list that will display certain fields from an opportunity's child quote records. The S-Docs related list generator provides a complete range of flexibility in developing templated related lists. For example, without even editing any code, you can adjust the formatting of the related list's table and columns, select any of the related list object's fields that you would like displayed in your table, and even filter/sort the related list rows by user-specified criteria. If you decide to go one step further and edit the related list source code, the possibilities for modification become endless.

This guide will discuss how you can use the S-Docs template editor to create a table with columns comprised of related list fields. In the following steps, we will be creating a very basic related list that might generate the following document:

Dev Guide - Adding a Related List (1)

The document above was generated from a template for an opportunity. In this template, we inserted a related list for an opportunity’s child quote records. You can find a list of more advanced related list column attributes in our Advanced Template Features document.

Note: This article goes over how to use the Insert Related List button to format your related list data into a table. If you have other formatting requirements, please see our guide to customizing your related list layout. You can also generate a separate document for each record in your related list. For extensive customization opportunities, you may also want to consider generating a component template for each record in your related list. This method allows you to format your data in a separate component template in any way that you like, and reference that component in your main template.

Use The "Insert Related List" Button

Now, let's begin! In the template editor for our opportunity template, start by clicking the Insert Related List button at the top of the page.

Select A Related List

The following window will appear.

[1] The drop-down menu under “Step 1: Select a Related List” allows you to select an available related list for your object. In this case, we selected the opportunitylineitems related list. You can also [2] choose to edit a related list that you've configured in this template before, if applicable.

In addition, [3] you're given the option to utilize the S-Docs Direct SOQL feature, which allows you to merge records from objects that aren't related to your base object, and much more. Find out more about the Direct SOQL feature in this documentation article.

Choose Table Columns

Scroll down to Step 2: Choose Table Columns to select fields from your related list object to be used as columns in the related list table.

To add a field as a column in your table, [1] click the name of that field and then click the button under “Add.” The topmost field will become the leftmost table column, but you can [2] rearrange the fields as necessary on this screen.

Note that some fields have this character to the right of them: “>.” These fields correspond to IDs of object records in our related list; clicking on them will bring up another menu where we can pull data from these object records.

After choosing the following fields, our related list columns would appear as follows:

This simple related list would output a numbered list of products related to this Opportunity, including product names, descriptions, quantities, and total prices.

Format Table Columns

After selecting all the columns you’d like to have in your related list, open the Format Data Columns tab.

Here, you can edit how each column will appear. By default, the current columns would be named “rownum,” “name,” "description," "quantity," and "totalprice." You can change these names under Header Text (Column Header). The other fields offer useful formatting options for each entry under the selected column. For the “totalprice” column in our example, we set the prefix text to “$” and the format number to #,###.## so that price entries will be formatted as currency.

Additional Table Formatting & Styles

After formatting your columns, click Formatting & Styles to apply even more formatting to your table. You can change the table style as a whole as well as change the formatting of the text in each individual column.

Filter & Change Row Order

You can also filter out rows and change the order in which the rows are sorted using SOQL and filter logic by accessing the Filters and Sort Order tab. Examples of filter logic are included under the description for each field in this tab: for example, using “Quantity > 1” in the first field would make our table only output products that have a quantity greater than 1. The other two fields allow us to limit the number of rows created in our table, and to sort our rows by filter logic or SOQL ORDER BY clauses.

Edit Source Code

Finally, view the Advanced tab to see the source code generated for the table you have been creating. You may edit the source here before inserting the table if you wish to fine tune your table’s qualities (you can also edit your related list in the template editor's source mode after inserting your related list). You can edit the CSS here in order to fine-tune the formatting of your table (e.g. border-width, font-size, the background color of even rows, etc.). If you'd like more control over your related list's layout, you can customize your related list code; extensive documentation on this can be found here.

Insert Your Related List

Click Insert to insert the table into your template.

Note that there is no data or fields present under the columns, as this is a template. The table will populate as expected upon document generation. If you wish to edit your table after insertion (such as adding and deleting certain fields it uses as columns), you can click Insert Related List again and select your related list under the Edit a Previous Related List section.

You may also edit it in the source editor. That's it! You are now ready to use related lists in your templates.


The S-Docs Template Editor

By Developer's Guide, Documentation No Comments
Note: The Insert Related List and Insert RENDER buttons are explained in separate articles.

Introduction

This document will explain how to use & navigate through the S-Docs template editor, including all of the buttons and tabs. The S-Docs template editor provides a powerful interface for creating attractive, data-driven documents. S-Docs templates are written in HTML, and the template editor provides two options for editing: a WYSIWYG editor (What You See Is What You Get) and an HTML Source editor. Changes made in one editor will be reflected in the other editor. For example, if you make text bold in the WYSIWYG editor, the text will be enclosed in <strong> tags in the source editor. Likewise, enclosing text in the source editor in <strong> tags would lead to bold text being displayed in the WYSIWYG editor.

Template Editor Tabs

Click a tab name to scroll down to its explanation.
Template Body
Header & Footer
Page Settings
Document Options
Email Settings
Auto Create Task
Runtime Prompts
Advanced Options

The Template Body Tab

This is the template body tab of the S-Docs template editor:

Click a number below to scroll down to its explanation.

1    |    2    |    3    |    4    |    5    |    6    |    7    |    8    |    9    |    10    |    11    |    12    |    13    |    14    |    15         16    |    17

An S-Doc template has a header, footer, and body, much like an MS Word document. Opening the template body tab reveals an editor for your template. Below are explanations of the components of this template editor. Note that you can hover over every button in the toolbar of the template editor for a very short description of that button’s function.

1) This is the WYSIWYG editor: the large, blank white area in the above image that looks similar to a blank Word document. WYSIWYG is an acronym for What You See Is What You Get, which perfectly describes the nature of this editor; you can create a template from scratch in this editor and when you generate the document down the road, it should appear the same as the content appears here. Use the tools in the toolbar to edit the content in this editor. [Back to Top]

2) The Source button switches from the WYSIWYG editor to the source editor, allowing you to edit the HTML and CSS that represents your template. Note that you cannot use any of the buttons in the toolbar in the source editor; they are reserved for use in the WYSIWYG editor. When you make changes in the WYSIWYG editor, the background source updates automatically to reflect those changes. While simple and intuitive, the WYSIWYG editor does not support the same level of template customization that the source editor does. Below is an example of a template in the WYSIWYG editor:

Here is that same template in the source editor:

[Back to Top]

3) This is the Maximize button. Clicking it will hide the tabs and buttons, and expand the WYSIWYG editor itself. [Back to Top]

4) This is the Show Blocks button. Clicking it will display the types of HTML tags that content is displayed in. In the following example, the information is between stored in <div> tags. Here it is first with Show Blocks turned off:

And here it is with Show Blocks turned on, exposing the DIVs:

[Back to Top]

5) These buttons are for Cutting, Copying, and Pasting, respectively. There are three different kinds of pastes: Paste simply pastes whatever is copied to the clipboard, Paste as plain text pastes plain text with the formatting and images of the original source removed, and Paste from Word will accurately paste content copied from MS Word. Note that there are a few considerations to take into account when using Paste from Word; click here to read more about this option. [Back to Top]

6) These are the Undo and Redo tools. Use them to undo or redo previous actions. [Back to Top]

7) These are the Find and Replace tools. Use Find to find words within your editor, and use Replace to replace all occurrences of a certain word/string with a different word/string. [Back to Top]

8) These are the Insert tools. Use them to insert images, tables, hyperlinks, and page breaks, respectively. [Back to Top]

9) This is the Styles menu. You can select text in your document and then select a style from the Styles menu to apply that style to the selected text. [Back to Top]

10) This is the Format menu. You can select text in your document and then select a style from the Format menu to apply that format to the selected text. [Back to Top]

11) This is the Font menu. Use it to change the font of selected text. [Back to Top]

12) This is the Size menu. Use it to change the size of selected text. [Back to Top]

13) These are the Font Color controls. Use them to to change text color and text background color. [Back to Top]

14) These are Text Formatting tools. Use them to make text bold, italic, underlined, stricken-through, or to remove all formatting of the selected text. [Back to Top]

15) These are List tools. Use them to create ordered or unordered lists, and to increase or decrease the indentation of these lists. [Back to Top]

16) These are Alignment tools. Use them to change the alignment of text on the page. [Back to Top]

17) This is the Line Height menu. You can use it to select the amount of spacing between a specific line. [Back to Top]

The HTML code in the source editor will automatically update at every change made to reflect the changes made in the WYSIWYG editor using the tools listed above.

The Header and Footer Tabs

The Header tab and the Footer tab are identical, with the obvious exception that the header tab can be used to add headers to your template and the footer tab can be used to add footers to your template. Here is the header tab:

Opening Header on First Page or Header on Remaining Pages will reveal the same editor discussed above in The Template Body Tab. You can use it to design your template header/footer in the exact same way that you design your template body. If you would like to have the same header/footer on every page, design your header/footer in the Header/Footer on First Page editor, and make sure the Use First Page Header/Footer for All Pages checkbox under Header/Footer on Remaining Pages is checked.

If you would like the first page to have its own header/footer, and for all remaining pages to share a different header/footer, uncheck this box and edit the header/footer for the first page in the Header/Footer on First Page tab, and edit the header/footer for all remaining pages in the Header/Footer on Remaining Pages tab.

The Page Settings Tab

The page settings tab contains controls for the width, height, and margins of the page. You can select inches, centimeters, or pixels as your unit of measurement and adjust the dimensions of the page and margins as you wish. Standard portrait and landscape options are provided for you in the Page Layout field; choosing either of these options will lock the Page Width and Page Height fields. You can select Custom instead to edit each field yourself.

The Document Options Tab

The Document Options tab contains four sections: Attachment & File Name Options, Attachment & File Options, Mass Merge Options, and Other Options.

Note: The Mass Merge Options will only appear if you have configured the S-Docs Mass Merge feature in your org.

Attachment & File Name Options:

By default, generated S-Docs are named something like SD-0001.pdf. In this field, you can change the name of generated S-Docs to whatever you’d like. You can use static text or merge fields. For example, setting “Proposal For {!Opportunity.Account.Name}” as the output file format would result in the generated S-Doc being Proposal For John Smith.pdf rather than the default SD-0019.pdf. Note that merge fields must use single braces as opposed to double.

Attachment & File Options

1 & 2: Here, you can choose to automatically create a Salesforce Attachment or Salesforce File that will show up in your base record's Files or Notes & Attachments related list each time a document is generated with this template.

3. This option will cause a new Salesforce Attachment to be created only if the document is emailed.

4. If you have opted to create a Salesforce Attachment or File each time this template is generated, the default behavior is to delete these related Attachments or Files whenever the corresponding S-Doc record is deleted. This is a clean-up measure. You can uncheck this box if you want to preserve all Attachments or Files regardless of linked record deletes.

5. This enables the Live Edit feature. When checked, end users will be able to edit this document in their browser after it is generated.

6. If the Live Edit feature is enabled, you can check this box so that users can rename new Salesforce Attachments that are created each time a user edits the generated document. This option only applies if checkbox #7 is checked.

7. If the Live Edit feature is enabled, you can check this box so that new attachments are automatically created each time a user edits the generated document.

Mass Merge Options:

Note: These options will only appear if you have configured the S-Docs Mass Merge feature in your org.

1. Checking this box will bring up the email page after the mass merge is finished and allow the user to email the consolidated document.

2. When a mass merge is created, a copy of the combined document will be saved in the Salesforce Documents folder. Checking this box will stop this from happening.

3. Choose to not create page breaks between documents during mass merge.

4. You can enter fields that you want documents to be sorted by in the mass merge and indicate the sort direction. Don't include the base object in this field; if you want to sort by {{!Opportunity.name}}, for example, you would just write "name asc" instead of "Opportunity.name."

  • To sort by a number field, specify asc/desc and add the "num" indicator. Example: "amount desc num"
  • To add multiple fields, separate them with commas.
  • Pro Tip: Use the Insert Field tool to make sure the field(s) after the base object is correct

5. An S-Doc Job is created for each record included in a mass merge. Checking this box will clear the S-Doc Jobs after the user clicks Combine all into single printable document. This keeps the system clean, but is not required.

6. An S-Doc Job is created for each record included in a mass merge. Checking this box will clear the S-Doc Jobs after the user clicks Send Email from the mass merge page. This keeps the system clean, but is not required.

7. Create a single summary doc in XML of all documents generated in the mass merge (XML format only)

8. You can create a page break after every n number of documents here. This is useful for things like receipts that are being printed.

Other Options:

1. Check this box if your template contains international characters; otherwise, they may not display.

2. Show all warning messages during document generation. If unchecked, S-Docs will only display critical error messages.

3. If your international characters aren't displaying correctly even when you check checkbox #1, you can set the Unicode Enforcement Level to "Data” or "Strict" to ensure that they display properly.

4. You can set the amount of template versions that you want to save in the version history. A new version is created each time you click Save in the template editor. The version history can be viewed on the template detail page.

5. If you are creating a document for a case, checking this box will automatically pull articles from that case and attach it to the outbound email along with the document.

6. Checking this box will save all merge field data within the document to an S-Doc Record as an XML field. This is useful if you want to use the merge field data after document generation.

7. Checking this box will redirect the user back to the base record after they generate this template.

The Email Settings Tab

The email settings tab contains options for controlling the behavior when this template is emailed. There are four sections in this tab: Email Subject Settings, Email Recipient Settings, Email Sender Settings, and Other Email Settings.

Email Subject Settings

1. Optionally enter an email subject. You can use static text or merge fields (make sure to use single braces as opposed to double).

2. Check this box to lock the Subject field to the end-user. If you leave the Subject field blank when this box is checked, the entire Subject field will be hidden on the S-Docs email page.

3. Check this box to require end-users to enter an email subject before emailing this document.

Email Recipient Settings

1. Optionally set the To, CC, or BCC email fields. You can use static text or merge fields (make sure to use single braces as opposed to double).

2. Lock the To, CC, or BCC fields so that end-users cannot edit them. Note that if you leave the To field blank when you lock it, this template will not be able to be emailed. If you leave the CC or BCC fields blank when you lock them, these fields will be hidden on the S-Docs email page.

Email Sender Settings

1. Choose to send this document from the email address of the logged in user, or from one of your Org-Wide email addresses.

2. Check this box to restrict the email From field to an org-wide email address. This prevents this document from being sent as the logged in user.

3. Check this box to allow the end-user to pick from a list of your Org-Wide email addresses to send this document from.

4. Check this box to allow users to use their Salesforce Email Signature in email body templates. You can insert the {{{!UserSignature}}} special merge field to reference the generating user's email signature once this box is checked.

Other Email Settings

1. Enter a comma-delimited list of email domains to restrict users from emailing this document to anyone outside of those domains. Example: sdocs.com,trailhead.edu

2. Check this box to prevent the end-user from modifying the email body when sending this document.

The Create Salesforce Task Tab

The Create Salesforce Task tab can be used to configure your template to automatically generate a Salesforce task whenever a document is generated using that template. This tab is hidden by default; to enable it, navigate to the SDocsSettings Custom Settings record (Setup > Custom Settings > SDocsSettings > Manage > Edit). Check the Enable Create Salesforce Task Feature checkbox.

There are four sections in the Create Salesforce Task tab: Salesforce Task Settings, Salesforce Task Subject, Salesforce Task Status, and Salesforce Task Activity Date.

Salesforce Task Settings

1. Check this box to enable the Create Salesforce Task feature and automatically create a new Salesforce task whenever this template is generated.

2. Check this box to allow the user to choose whether or not a Salesforce Task should be created each time this template is generated.

3. Check this box to allow the user to edit the details of the Salesforce Task for this document before it's created.

Salesforce Task Subject

You can optionally enter a Salesforce Task subject here. You can use static text or merge fields (make sure to use single braces as opposed to double). If you do not enter a subject, it will default to "S-Doc Generated:Template_Name."

Salesforce Task Status

You can optionally enter a Salesforce Task status. You can use static text and merge fields (make sure to use single braces as opposed to double). If you do not enter a status, it will default to Completed and go directly to the Activity History list, as opposed to the Open Activities list.

Salesforce Task Activity Date

1. Optionally enter the number of days until this task is due. If this field is left blank, the due date will default to the date that the document is generated on.

2. Check this box to count only weekdays when calculating the task due date (weekends will be excluded, but holidays will be included).

The Runtime Prompts Tab

In this tab, you can create text, date, checkbox, or related list prompts for users to input information into during document generation. User input will then be merged into the document at runtime based on merge fields that you define. Click here for an in-depth explanation of runtime prompts.

The Advanced Options Tab

The Advanced Options tab contains three sections: Advanced Template Settings, Export Template, and Configure Contact Lookup.

Advanced Template Settings

1. The Enable S-Sign checkbox will open up the S-Sign e-signature panel, which allows you to add e-signature tags to your template (along with other types of input) and send the generated document for e-signature with our e-signature add-on product S-Sign. The checkbox will be disabled unless you've downloaded the trial or full version of S-Sign. For more information about installing and configuring S-Sign, click here.

2. The Preview ID field allows you to enter a Salesforce record ID, and then preview the final generated document using data from that record. When you enter an ID into this field, a Save & Preview button will appear at the top of the template editor. Clicking this button will Save your template and generate a preview document in a new tab.

Export Template

To move this template between orgs, you can click Generate to generate a string of importable template data that can be used to create a clone of this template in another org. Click here to learn more about exporting individual templates. Click here to learn more about exporting large numbers of templates.

Configure Contact Lookup

Templates with a Related To Type of Opportunity or Account can contain a number of special contact merge fields. When these fields are included in a template, the user will be able to select contact records during the document generation process that should be merged into the document. This list includes contact records related to the base record that the template is generated from; however, [1] the Additional Contact Roles for Lookup list in this section allows you to choose additional objects for S-Docs to query for contact records. Any records found will be added to the contact selection picklist.

[2] If you would like to limit which contacts show up in this list, you can input a WHERE clause (omitting the WHERE) that dictates which contacts should appear in this list. Note that this query will affect the contact picker for special contact merge fields and the S-Docs Email page.

Note: This section only appears for templates with a Related To Type of Opportunity or Account.

Template Editor Buttons

These are the Template Editor buttons. Click a number to scroll down or be redirected to its explanation.

1    |    2    |    3    |    4    |

1. Save, Save & Close, Cancel

Save saves your work. Save and Close saves you work and takes you back to the template detail page. Cancel removes all edits made after the last save and take you back to the template detail page.

2. Insert Field

Clicking this button will bring up the Insert Field menu.

Object Fields

The first tab of this menu contains all of the fields from the template's base object (which was set when the template was created) that are available to the user who is editing the template. If certain fields are restricted from the user, they will not show up here. Since our example template's base object is Opportunity, we see opportunity fields.

1. Select a field from the list.

2. If your field requires formatting (such as number or date fields), you can select how you want the data to display using the picklist below the field menu.

3. You can click Insert to insert the merge field wherever your cursor last was in the template editor, or click Copy to Clipboard to copy the field and paste it yourself.

The Insert button will only work in the Template Body tab; if you are working in the Source of the Template Editor, for example, or you want to insert a field into a Header, you will need to copy and paste it manually.

If a field name has a > symbol at the end of it, that means that it's a lookup field for another object. Clicking it will bring up all available fields for that object. You can click lookup fields in that object as well, but you are limited to 5 layers.

Runtime Prompts Fields

The Runtime Prompt Fields tab will show any runtime prompts that you have defined, and allow you to insert them.

Special Merge Fields

The Special Merge Fields tab shows fields that S-Docs has defined. To view an explanation of each special merge field, click here.

The Other Templates tab will allow you to easily insert one template into another as a merge field. These are called component templates. All available component templates will be listed under this tab in the following format: [Object] Template Name. To learn how to configure templates to be used as merge fields in other templates, click here.

The Insert Related List and Insert Conditional Logic buttons are explained in detail in separate articles.


Top