These custom functions are useful for establishing which base entities are included in a template, which in turn can make looping and iterating throughout the document faster and easier.
This function is useful for where a document should go to both client and partner if a partner exists. This function adds further redundancy by excluding the partner if they have a deceased status. By having this function you can cut down on a lot of unnecessary if $partner conditions as well as making your loops much more efficient and streamlined.
<:let adviceList=[$client, $partner] if $client.is_individual and $client.marriage_partner and ($client.marriage_partner.entity_client_status.value)!=’64’ else [$client]:>
In this example below, the adviceList helps us to cut out coding checking for the $partner, because we’ve already done it in that function.
<:=joinList([getFullName(x) for x in adviceList]):>
output: John Smith and Jane Doe
Faster loops and iterations
In the example below we are looping through all the entities for the document and outputting the names of their superannuation fund.
Typically most templates would have one loop for the client and another loop after an if $partner condition. Using adviceList in the method below completely cuts out the need for multiple loops and conditions because its all been handled up front.
<:forentity in adviceList:>
<:for item in entity.fund:>
Fund Name <:=item.fund_name:>
Group Owners List
There are a variety of standard elements in Xplan – and also custom group use cases – where you will have data that is stored against a single entity and it has an owner or “who for” like field, that is used to define who an individual item in the group belongs to. Common examples of this are assets and liabilities, cashflow, strategy groups etc.
By defining a list of owners in a similar fashion as an entityList can help streamline coding around data like this:
<:let ownerList=[‘Client’, ‘Partner’, ‘Joint’] if $client.is_individual and $client.marriage_partner else [‘Client’, ‘Joint’]:>
Traditionally to output a list of all assets against client/partner/joint you would see three separate loops and if statements.
By defining this up front the heavy lifting is done once and we can streamline our coding and loops. In the example below if this was run against a client record that had a partner, the client, partner and joint asset name (or type) would all merge through:
<:forentity in ownerList:>
<:for item in [x for x in entity.asset if str(x.owner) == str(entity)]:>
Asset: <:=item.desc if item.desc else item.type:>
Defining the function
Recommend you define this function at the start of your template so that you can call it throughout the template as needed.
Naming the function
These custom functions and declarations can be called whatever you like, just try to keep them consistent and easy to read for yourself and others – something logically related to the purpose of the function, usually helps.
Xmerge is case sensitive too so try to adopt a consist structure in how you name your variousFunctions.
Documents created via Xmerge can have a unique system-generated barcode inserted into the output documents. This barcode can be associated with one or more actions. Learn how to generate these barcodes through xmerge.