Menu

join()

Updated: 2024-11-11

Join field codes with a specified separator using the join() function. This shortens the code and allows you to use the same code for single taxpayers and spouses because TaxCycle will not add the separator if the field is empty for one of the field codes.

You can also nest the join function for further effect. For example, this is useful if you need to say "Mr Sims" if the taxpayer is single, but "Mr & Mrs Sims" when the taxpayer has a spouse. Use the following code:

{{ join(" ", join(" & ", CurrentClient.Info.ID.Title, CurrentClient.Info.SpouseID.Title), CurrentClient.Info.ID.LastName) }}

For a single taxpayer, it displays: Mr Sims. For a taxpayer with a spouse, it displays Mr & Mrs Sims.

Salutation with the last name, whether single or coupled

Code Possible Results
{{ join(" ", join(" & ", CurrentClient.Info.ID.Title, CurrentClient.Info.SpouseID.Title), CurrentClient.Info.ID.LastName) }} Mr Chan

Mr & Mrs Sims

Just first names, whether coupled or single

Code Possible Results
{{ join(" & ", CurrentClient.Info.ID.FirstName, CurrentClient.Info.SpouseID.FirstName) }}

Howard

Howard & Juliette

Test for different first or last names

Code Possible Results
{{#CurrentClient.Info.ID.LastName = CurrentClient.Info.SpouseID.LastName}}
{{ join(" ", join(" & ", CurrentClient.Info.ID.FirstName, CurrentClient.Info.SpouseID.FirstName), CurrentClient.Info.ID.LastName) }}
{{/CurrentClient.Info.ID.LastName = CurrentClient.Info.SpouseID.LastName}}
{{#CurrentClient.Info.ID.LastName != CurrentClient.Info.SpouseID.LastName}}
{{ join(" & ", join(" ", CurrentClient.Info.ID.FirstName, CurrentClient.Info.ID.LastName), join(" ", CurrentClient.Info.SpouseID.FirstName, CurrentClient.Info.SpouseID.LastName)) }}
{{/CurrentClient.Info.ID.LastName != CurrentClient.Info.SpouseID.LastName}}

Howard Chan

Thomas & Abigail Sims

Howard Chan & Juliette Thompson

More examples

Code Result
{{join(" ", CurrentClient.Info.ID.FirstName, CurrentClient.Info.Info.ID.Initial, CurrentClient.Info.ID.LastName) }} James Fielding
{{join(", ", CurrentClient.Info.ID.LastName, join(" ", CurrentClient.Info.ID.FirstName, CurrentClient.Info.ID.Initial)) }} Fielding, James
{{join(" ", CurrentClient.Info.ID.Title, CurrentClient.Info.ID.FirstName, CurrentClient.Info.ID.LastName) }} Mr James Fielding
{{join(" ", join(" & ", CurrentClient.Info.ID.Title, Info.SpouseID.Title), CurrentClient.Info.ID.LastName) }} Mr & Mrs Fielding