Menu

SFDC DOCX ATTACHMENT

Provides commands for appending other DOCX documents from Salesforce to the end of composed DOCX documents.

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

appendNamedSection

Appends the contents of a DOCX document stored in a Salesforce record with a name matching the specified conditions at the end of the current document, possibly as a new section.  

If the appended document is a template, it is composed 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 appended template have access to all variables, except for external parameters, of this main template.

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

Unlike with the appendSection command, the attributes specifying the document to be appended may match more than one document. If this happens, it is considered an error and the commands'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.

Please note that appending works in a slightly different manner depending on if the template is Flow- or Controller-based when there are multiple commands doing the appending. In a Flow, all appended documents always appear in the result document in the order that the commands are evaluated. In a Controller, the same thing happens by default, but the position attribute may also be used to control the order. The position attribute does nothing in a Flow.  

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

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 append. This attribute together with the where attribute defines the appended 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 append. 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 appended content whose names conflict with styles in the base document. The appending process brings all styles of the appended 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 appended 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 appended content and bringing them into the base document with their new names. As the appended 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 appended document's style into the base document. The appended content referring to a conflicting style will then start to refer to the style of the base document with the conflicting name. Any appended content referring to non-conflicting styles will still preserve its original look.

If undefined, the value true is used. 
position

Required
Value type
EL-evaluated
No Integer No
This attribute can be used to define the order in which the appended documents appear in the result, should there be more than one appendSection or another kind of command doing a similar job. The smaller the value, the earlier the document appears in the sequence of appendices. If more than one command define the same position, the order in which they appear is defined by the order in which the commands are evaluated.

Note that this attribute does not do anything if this command in a Flow.

If this attribute is left undefined, the appended document is placed after all appendices that had their position defined. With more than one command that have position undefined, the order is defined by the order in which the commands are evaluated.
inheritHeadersFooters

Required
Value type
EL-evaluated
No String Yes
Defines if the header and footer references present in the appended content are removed, therefore forcing the section to inherit the headers and footers of the section preceding it. This will be the case if the resolved value is true.

If not defined, this attribute's value defaults to false, allowing the appended content to keep its original headers and footers.
sectionBreak


Required
Value type
EL-evaluated
No
String
Yes
This attribute defines what kind of a section break, if any, is placed between the main document content and the appended content.

The possible values are:
  • nextPage
  • evenPage
  • oddPage
  • continuous
  • none
The first four produce a section break of the specified type. The last value "none" is special, resulting in no section break to be created, which then causes the appended content's first section to become a part of the main content's last section.

If left undefined, the value of nextPage is used, producing a standard page break before the appended the content.
alias

Required
Value type
EL-evaluated
No String Yes
Defines an alias for the document that this command appends. The alias is displayed in Office add-in and is purely an informational value - it does not have any effect on the command's functionality.
test

Required
Value type
EL-evaluated
No Boolean Yes
This attribute can be used to make the appendix produced by this command conditional. Should this attribute be undefined or resolve into true, the appending happens normally, but if the resolved value is false, no appending is done.

Restrictions

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

appendSection

Appends the contents of a DOCX document stored in the specified Salesforce record at the end of the current document, possibly as a new section.  

If the appended document is a template, it is composed 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 appended template have access to all variables, except for external parameters, of this main template.

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

Please note that appending works in a slightly different manner depending on if the template is Flow- or Controller-based when there are multiple commands doing the appending. In a Flow, all appended documents always appear in the result document in the order that the commands are evaluated. In a Controller, the same thing happens by default, but the position attribute may also be used to control the order. The position attribute does nothing in a Flow.  

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

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 appended.
versionID

Required
Value type
EL-evaluated
No String Yes
This attribute can be used to define a specific version of the document to append. 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 appended content whose names conflict with styles in the base document. The appending process brings all styles of the appended 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 appended 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 appended content and bringing them into the base document with their new names. As the appended 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 appended document's style into the base document. The appended content referring to a conflicting style will then start to refer to the style of the base document with the conflicting name. Any appended content referring to non-conflicting styles will still preserve its original look.

If undefined, the value true is used. 
position

Required
Value type
EL-evaluated
No Integer No
This attribute can be used to define the order in which the appended documents appear in the result, should there be more than one appendSection or another kind of command doing a similar job. The smaller the value, the earlier the document appears in the sequence of appendices. If more than one command define the same position, the order in which they appear is defined by the order in which the commands are evaluated.

Note that this attribute does not do anything if this command is in a Flow.

If this attribute is left undefined, the appended document is placed after all appendices that had their position defined. With more than one command that have position undefined, the order is defined by the order in which the commands are evaluated.
inheritHeadersFooters

Required
Value type
EL-evaluated
No String Yes
Defines if the header and footer references present in the appended content are removed, therefore forcing the section to inherit the headers and footers of the section preceding it. This will be the case if the resolved value is true.

If not defined, this attribute's value defaults to false, allowing the appended content to keep its original headers and footers.
sectionBreak


Required
Value type
EL-evaluated
No
String
Yes
This attribute defines what kind of a section break, if any, is placed between the main document content and the appended content.

The possible values are:
  • nextPage
  • evenPage
  • oddPage
  • continuous
  • none
The first four produce a section break of the specified type. The last value "none" is special, resulting in no section break to be created, which then causes the appended content's first section to become a part of the main content's last section.

If left undefined, the value of nextPage is used, producing a standard page break before the appended the content.
alias

Required
Value type
EL-evaluated
No String Yes
Defines an alias for the document that this command appends. The alias is displayed in Office add-in and is purely an informational value - it does not have any effect on the command's functionality.
test

Required
Value type
EL-evaluated
No Boolean Yes
This attribute can be used to make the appendix produced by this command conditional. Should this attribute be undefined or resolve into true, the appending happens normally, but if the resolved value is false, no appending is done.

Restrictions

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

Comments

0 comments