Element Attributes
Element attributes provide additional information about the element.
Element attributes are visible and configurable from the Attributes tab under Element in the right-hand pane of the template editor (see screenshot below).
There are 4 main element attributes:
Content
Condition
Content Format
Repeat
Content
Content is an HTML content command that brings text or document content into its host element. Simply put, this is the field that needs to be filled in to bind data with the template in order to populate specified areas with dynamic content.
The Content command allows populating one single data item. If several items (i.e. from a list or a collection) need to be populated, the Repeat content command is used (see below).
The command uses expression language to define what needs to be populated. However, there is no need to type the command in manually - the easiest way to add data binding is to use the data mapper in the Data Source
tab. It allows picking data sources from a list.
The value being populated as per the command will replace the template element placeholder value. The placeholder value can be anything, but if the element was added using the data mapper, the content automatically populates with the value varName
, where varName
can be a variable name or Salesforce field.
For example in the image below, [Company Name]
is mapped with Salesforce field CompanyName
, which is a field under Owner of the selected Opportunity record (the template’s main object is Opportunity).
Condition (If attribute)
Data item value can also act as a condition when bound to an element with the if
attribute. The condition is used to display or hide the element. If the EL expression value is true, the element will be part of the output document. Otherwise, the element is removed from the output document. For example, if a Salesforce data field should not be visible because the Salesforce value is empty, not empty varName
can be entered to the if
attribute.
For example, if a Salesforce field called CompanyName under Owner might be empty in Salesforce, then the If condition can be used to make sure that the placeholder element for that field will not be visible in the finalised document. This is how the condition would be written:
not empty Opportunity.Owner.CompanyName.
Content Format
Formatting of the actual value can be defined with the content format attribute. For example, if a custom format yearOnly
has been created for a date value to display only year ‘yyyy', then its format name can be selected or manually entered inside '’ quotations.
Repeat
Repeat allows the element to iterate through a list of items (such as a Salesforce Related List) to display all the items inside that list. When using the Repeat function, the Repeat
and Repeat: Variable
should always be defined.
For example, an Opportunity Line Item Related list can be accessed and iterated to display a list of products which are related to the Opportunity. In the image below, the Product table has the Row element repeated with opportunityLineItems
in Repeat and i
as Repeat: Variable.
When Repeat: Variable
is defined, such variable name should be used to indicate in the child elements inside that repeat to refer to the field (or key) exist in the item.
For example, Product2.Name being a field under Opportunity Line Item where previously (image above) each item indicates as an i
in the repeat. Then in this <span> element (a child HTML element of Row, can be seen from the breadcrumbs), to correctly map or refer to the Salesforce field, it should be written as i.Product2.Name
Repeat: Round Start
This attribute can be used to define a condition for skipping certain iteration rounds. This attribute's expression is evaluated at the start of every round and if it doesn't resolve into true
, the current item and loop round is skipped, resulting in no copy of the content being produced. If undefined, no iteration rounds are skipped.
For example, the above product table needs to exclude the item that has Quantity above 10: By entering ‘i.Quantity < 10’ to Repeat: Round Start
, the table will skip those items that has quantity more than 10 and only shows those quantity below 10.
Repeat: Status Variable
Defines the name of the variable that holds a Loop Status value. Loop Status has the properties count
, first
, last
and index
. A new value is generated for every iteration of the loop. More information is available here: repeat.
Once a new Repeat: Status Variable
is created, it can be used in other lower elements to make conditions. For example, below, ‘status’ is entered as a new status value to the repeating row.
Then in the lower element, status.first
which resolves into a Boolean value can be used to display or hide certain content. In this example, the iteration will only display the Name of the first item and hide the Name of others.