Menu

SFDC DOCX

Provides commands for inserting content from Salesforce into DOCX documents.

Commands of this library may only be used in DOCX document content.

bind

Creates a two-way binding between a Salesforce field and the content of this command's content control.

What this means is that this command produces text output like an out command, with a specified record's field's value as the value to output. And then with the help of the updateRecords command, the possibly edited text content within this command's content control can be uploaded back into Salesforce to become the field's new value.

To function properly, this command needs to get its output specifically from a variable in the base variable context produced by a record command. For example, if a record command's var attribute value is "opportunityRecord", then a proper value expression for bind could be "${opportunityRecord.Amount}". Should the bind's value expression not give this hint of its data's source, an error will occur when using updateRecords to get the data into Salesforce. 

Due to the need of this command being able to define content input, it and its content control will always remain in the document after evaluation regardless of the document's Smart content status.

Attributes

value

Required
Value type
EL-evaluated
Yes Any Yes
Defines the text output of this command. The resolved value can be of any type, but to make the data upload functionality work, the value should be something produced by a record command, as described in this command's documentation.  
required


Required
Value type
EL-evaluated
No Boolean Yes
Defines if this command is required to have a value to output. If this attribute's resolved value is true and the value attribute resolves into null, the user is informed with an error message.

If undefined, value of false is used, allowing value to resolve into null.
title

Required
Value type
EL-evaluated
No String Yes
Defines the title of this command's content control.
tagLogic

Required
Value type
EL-evaluated
No String Yes
Specifies the tag logic that will be executed right before the evaluation of this command. The resolved String is expected to be the name of a tag controller.
importContent

Replaces contents of this command's content control with the contents of a DOCX document stored in Salesforce.

If the imported document is a template, it is imported before being appended. It can be Controller or Flow-based; if Flow-based, the Flow with the ID "compose" will be run. Commands in the imported template have access to all variables, except for external parameters, of this main template.

If this command's content control is in a paragraph with other content, the results vary slightly depending on the imported content. If the imported content consists of a single paragraph, that paragraph's content is merged into the paragraph surrounding the content control. If the imported content consists of more than one paragraph, the surrounding paragraph is split into two paragraphs and the content is placed between these two paragraphs.

Note that imported templates are not permitted to import or append more documents. Therefore the following commands are not evaluated if encountered during composing of an imported template:

The importContent command produces a local variable context that is the active context for the duration of the imported template's composing process. While most variables that the imported template's logic creates stay within this local context, be aware that any set commands may overwrite variables in the template initiating the importing.

Attributes

docID

Required
Value type
EL-evaluated
Yes String Yes
Defines the ID of the ContentDocument record representing the DOCX document that is to be imported.
versionID

Required
Value type
EL-evaluated
No String Yes
This attribute can be used to define a specific version of the document to import. The resolved String should be the ID of a ContentVersion record associated with the ContentDocument defined with the docID attribute.

If undefined, the latest version of the document is picked.
renameConflictingStyles

Required
Value type
EL-evaluated
No Boolean No
Defines what will happen to styles in the imported content whose names conflict with styles in the base document. The importing process brings all styles of the imported document into the base document, but two styles with the same name cannot exist in a document and it is quite typical to have a style called "Normal", for example. Which "Normal" would an imported paragraph referring to a style with this name then take? This attribute offers two options to how such conflicts are resolved.

If this attribute's value is true, the conflict is resolved by renaming the conflicting styles of the imported content and bringing them into the base document with their new names. As the imported content's styles continue to exist in the resulting document with new names, all of the content preserves its original formatting. Do note that this causes any numbering sequence to restart as numberings are tied to specific styles.

If this attribute's value is false, the conflict is resolved by not bringing in the imported document's style into the base document. The imported content referring to a conflicting style will then start to refer to the style of the base document with the conflicting name. Any imported content referring to non-conflicting styles will still preserve its original look.

If undefined, the value false is used. 
test

Required
Value type
EL-evaluated
No Boolean Yes
This attribute can be used to make this command's content control a conditional element. If this attribute is undefined or if the resolved value is true, the command is evaluated normally and nothing special happens. If the resolved value is false, both the content control and any content inside it are removed and no content is imported.
tagLogic

Required
Value type
EL-evaluated
No String Yes
Specifies the tag logic that will be executed right before the evaluation of this command. The resolved String is expected to be the name of a tag controller.

Restrictions

The importContent command may be evaluated up to 20 times within a single evaluation process.

importNamedContent

Replaces contents of this command's content control with the contents of a DOCX document stored in a Salesforce record with a name matching the specified conditions.

If the imported document is a template, it is imported before being appended. It can be Controller or Flow-based; if Flow-based, the Flow with the ID "compose" will be run. Commands in the imported template have access to all variables, except for external parameters, of this main template.

If this command's content control is in a paragraph with other content, the results vary slightly depending on the imported content. If the imported content consists of a single paragraph, that paragraph's content is merged into the paragraph surrounding the content control. If the imported content consists of more than one paragraph, the surrounding paragraph is split into two paragraphs and the content is placed between these two paragraphs.

Note that imported templates are not permitted to import or append more documents. Therefore the following commands are not evaluated if encountered during composing of an imported template:

Unlike with the importContent command, the attributes specifying the document to be imported may match more than one document. If this happens, it is considered an error and the command's evaluation stops. Specifying the title more accurately or adding more conditions using the where attribute can help in narrowing down the amount of matching documents.

The importNamedContent command produces a local variable context that is the active context for the duration of the imported template's composing process. While most variables that the imported template's logic creates stay within this local context, be aware that any set commands may overwrite variables in the template initiating the importing.

Attributes

title

Required
Value type
EL-evaluated
Yes String Yes
Defines a full or a partial title of the ContentDocument record that has the DOCX document to import. This attribute together with the where attribute defines the imported document.

The resolved String may have wildcard characters '%' and '_'. The '%' wildcard matches zero or more characters, while the '_' matches exactly one character. These wildcards are the same as the ones used in SOQL's LIKE comparison operator.
where

Required
Value type
EL-evaluated
No String Yes
Defines additional conditions used to find the record with the document content to import. The resolved String is added to the WHERE clause of the SOQL query with which the record is searched. The query is targeted at the ContentVersion object type, so use that type's fields and references to form the conditions.
renameConflictingStyles

Required
Value type
EL-evaluated
No Boolean No
Defines what will happen to styles in the imported content whose names conflict with styles in the base document. The importing process brings all styles of the imported document into the base document, but two styles with the same name cannot exist in a document and it is quite typical to have a style called "Normal", for example. Which "Normal" would an imported paragraph referring to a style with this name then take? This attribute offers two options to how such conflicts are resolved.

If this attribute's value is true, the conflict is resolved by renaming the conflicting styles of the imported content and bringing them into the base document with their new names. As the imported content's styles continue to exist in the resulting document with new names, all of the content preserves its original formatting. Do note that this causes any numbering sequence to restart as numberings are tied to specific styles.

If this attribute's value is false, the conflict is resolved by not bringing in the imported document's style into the base document. The imported content referring to a conflicting style will then start to refer to the style of the base document with the conflicting name. Any imported content referring to non-conflicting styles will still preserve its original look.

If undefined, the value false is used. 
test

Required
Value type
EL-evaluated
No Boolean Yes
This attribute can be used to make this command's content control a conditional element. If this attribute is undefined or if the resolved value is true, the command is evaluated normally and nothing special happens. If the resolved value is false, both the content control and any content inside it are removed and no content is imported.
tagLogic

Required
Value type
EL-evaluated
No String Yes
Specifies the tag logic that will be executed right before the evaluation of this command. The resolved String is expected to be the name of a tag controller.

Restrictions

The importNamedContent command may be evaluated up to 20 times within a single evaluation process.

Comments

0 comments