enfr

Field codes

Updated: 2018-08-23

Field codes and constants are the basis of any expressions you create in the Template Editor or the Data Monitor, so understanding how to add and format them is the first step to building conditional content. Please read this topic before moving on to building conditions.

Copying field codes

Field codes allow you to pull information from a tax return's data. They are also used to build conditional statements. Use field codes in templates, data monitors and in print set conditions. Field codes used in templates, along with constants and conditions are enclosed in double braces {{ }} (curly brackets).

Right click to copy a field code

Right click on the field and select one of the Copy field code options:

  1. Copy field code puts the code on your clipboard without brackets. For example: CurrentClient.Engage.Preparer.ClientID. Use this in the Data Monitor, as well as in print set and template conditions.
  2. Copy field code with {{curly brackets}} puts the code on your clipboard with the curly brackets. For example: {{CurrentClient.Engage.Preparer.OfficeID}}. Use this format in Templates.

2018-right-click-copy-field-code636808346631937638

Click on the blue bar at the bottom of the window

  1. In an open tax return, place your cursor in the field on a form that you want to insert into the template.
  2. Click the field code link on the left in the blue bar at the bottom of the TaxCycle window. This copies the field code to your clipboard, ready to paste into the template. (Hold down the Ctrl key as you click to copy the field code without the CurrentClient. prefix.)
    Click the hyperlink to put the field code onto your clipboard
  3. Paste the code into the template. For example, {{CurrentClient.Info.ID.FirstName}} will insert the first name of the client (as long as there is a first name in the field).

Formatting field codes

If you want a field code to display a number or date in a particular way, you must format it to get the result  you want. Learn how to format the following:

Learn how to create and edit expressions in templates, data monitors and print conditions. 

Constants and hidden field codes

Some codes don't appear on forms, but can still be used to pull data about the client and the return. Look at the following pages for information on constants and hidden field codes:

Breaking up field codes

Field codes are divided into parts that narrow down the content within a tax return. You can divide them up to figure out what form they appear on or to shorten your statement if all the content you are pulling is from the same form. Let's look at an example to better explain.

The following is the field code for the First name field on the Info worksheet in TaxCycle T1. This is exactly how it would appear if you copy it from the field.

{{CurrentClient.Info.ID.FirstName}}

CurrentClient This tells the Template Editor to pull the data from the visible or active client. For example, if you are printing a letter from a tax return for the principal taxpayer (not the spouse). But, if you are viewing the tax return of the spouse, it will pull information from the spouse, CurrentClient refers to the principal taxpayer. On the other hand, if you are viewing the letter for the principal taxpayer, but you want to include information for the spouse, you would use CurrentSpouse instead.
Info This points to the Info worksheet.
ID This points to the ID section on the Info worksheet.
FirstName This points to the specific name field for the client's first name, within the Info worksheet, under the ID section.

You can use these components to simplify your code. For example, look at the following pieces of code for inserting the taxpayer's address in a letter. By turning the common parts of this group of field codes into a condition (creating an opening statement of {{# CurrentClient.Info }} and a closing statement of {{/ CurrentClient.Info }}. They both do the same thing, but the one on the left is much easier to read and work with.

{{# CurrentClient.Info }}

{{ ID.FirstName }} {{ ID.LastName }}
{{# Address.CareOf }}{{ . }}
{{/ Address.CareOf }} {{# Address.POBox or Address.POBoxLocation }}{{# Address.POBox }}PO Box {{ . }}{{/ Address.POBox }} {{ Address.POBoxLocation }}
{{/ Address.POBox or Address.POBoxLocation }} {{# Address.RuralRoute }}RR {{ . }}
{{/ Address.RuralRoute }} {{# Address.Apartment }}{{ . }} - {{/ Address.Apartment }}{{# Address.Street }}{{ . }}
{{/ Address.Street }} {{# Address.City or Address.Province }}{{ Address.City }}{{# Address.City and Address.Province }}, {{/ Address.City and Address.Province }}{{ abbreviate(Address.Province) }} {{/ Address.City or Address.Province }} {{ format(Address.PostalCode) }}

Dear {{ ID.FirstName }} {{ ID.LastName }},

{{/ CurrentClient.Info }}

{{ CurrentClient.Info.ID.FirstName }} {{ CurrentClient.Info.ID.LastName }}
{{# CurrentClient.Info.Address.CareOf }}{{ . }}
{{/ CurrentClient.Info.Address.CareOf }} {{# CurrentClient.Info.Address.POBox or CurrentClient.Info.Address.POBoxLocation }}{{# CurrentClient.Info.Address.POBox }}PO Box {{ . }}{{/ CurrentClient.Info.Address.POBox }} {{ CurrentClient.Info.Address.POBoxLocation }}
{{/ CurrentClient.Info.Address.POBox or CurrentClient.Info.Address.POBoxLocation }} {{# CurrentClient.Info.Address.RuralRoute }}RR {{ . }}
{{/ CurrentClient.Info.Address.RuralRoute }} {{# CurrentClient.Info.Address.Apartment }}{{ . }} - {{/ CurrentClient.Info.Address.Apartment }}{{# CurrentClient.Info.Address.Street }}{{ . }}
{{/ CurrentClient.Info.Address.Street }} {{# CurrentClient.Info.Address.City or CurrentClient.Info.Address.Province }}{{ CurrentClient.Info.Address.City }}{{# CurrentClient.Info.Address.City and CurrentClient.Info.Address.Province }}, {{/ CurrentClient.Info.Address.City and CurrentClient.Info.Address.Province }}{{ abbreviate(CurrentClient.Info.Address.Province) }} {{/ CurrentClient.Info.Address.City or CurrentClient.Info.Address.Province }} {{ format(CurrentClient.Info.Address.PostalCode) }}

Dear {{ CurrentClient.Info.ID.FirstName }} {{ CurrentClient.Info.ID.LastName }},

Why is this important? Not only does it help you read the code more easily, but as you move on to create your own conditions, you will likely look at built-in templates where we have simplified the code quite in this way. If you copy and paste existing code from there into a new template, it helps to know that you might need the {{# CurrentClient }} parent tag or the CurrentClient. prefix  (or others) to make the code work.

Field codes for multi-copy forms and slips

The field codes from multi-copy forms or slips contain a number in them to refer to the specific copy. For example:

Slip 1:

{{T4Slips.T4[0].CurrentYear.M[2]}}

Slip 2:

{{T4Slips.T4[1].CurrentYear.M[2]}}

Slip 3:

{{T4Slips.T4[2].CurrentYear.M[2]}}

The [0], [1] and [2] indicate different copies of the same type of slip, in this case the T4 slip. 

The numbering of a form or slip always starts at zero. If you see a [-1], it refers to a blank slip. This changes when you start typing in the form or slip.

Field codes expanding tables

The field codes from expanding tables contain a number in them to refer to the specific row. For example:

Row 1:

{{MedicalExpenses.ExpensesDetails[0].Amount}}

Row 2:

{{MedicalExpenses.ExpensesDetails[1].Amount}}

Row 3:

{{MedicalExpenses.ExpensesDetails[2].Amount}} 

The numbering of a row always starts at zero. If you see a [-1], it refers to a blank row. This changes when you start typing in the row. 

Mask function

You ca mask the output from a field code by adding mask( ) around the field code. For example, if you want to partially hide a bank account number, social insurance number or phone number. It is not required, but we recommend using the format( ) tag as well so that you retain the format even though it is masked. A few examples:

Mask preview and result

Aggregate function

You can aggregate amounts from a field on a particular form. This looks at that field on all the forms in a multi-copy form and adds them together, without specifying the field on each form.

  1. Place parentheses ( ) around the field code, within the double braces {{ }} (curly brackets).
  2. Add aggregate in front of the opening parenthesis ( (do not leave any space between it and the parentheses).
  3. Remove the [0], or other number, after the form type.
  4. Add a comma, and then enclose the remaining of the field code in parentheses.
Example Sample result
{{CurrentClient.T2125Forms[0].T2125.Expenses.GrossProfit}}
{{CurrentClient.T2125Forms[1].T2125.Expenses.GrossProfit}}

17776 (on the first T2125)
82738 (on the second T2125)

{{aggregate(CurrentClient.T2125Forms,"T2125.Expenses.GrossProfit")}}

100514

{{format(aggregate(CurrentClient.T2125Forms,"T2125.Expenses.GrossProfit"))}}

100,514 

Find values for check boxes

To display the value of a check box, add the the box to the Data Monitor:

  1. Check any one of the boxes in the list and don't move another field, so that one of the boxes in the list remains in focus.
  2. Click the plus sign on the far right of the data monitor to add the field to the Data Monitor. 
  3. The field name or line number shows on the left side of the Data Monitor.
  4. The value for the box that is currently checked is on the right side. This is the exact value to use when creating a condition with that check box. Check each box one at a time to see its value.

Add a group of check boxes to the Data Monitor to see the value for each box.

Most check boxes in TaxCycle allow you to select only one from the list, like the principal residence question on T1 Schedule 3. These style of check boxes have a single name in the left side of the data monitor and different values associated with each box. 

Other check boxes allow you to select all that apply to a question. Such as the questions in Part A of the T1135. Behind the scenes, these are different. Each box has a different name and value, so you need to add each box to the Data Monitor to see the value, rather than adding just one and switching between them.


Copy or export workflow ids

You can use workflow items in conditions in templates. To copy the ids from the workflow screen:

  1. With a file open, go to the File menu and click on Info.
  2. Right-click on a workflow item and select Copy ID for Template.
    copy-workflow-id
  3. In options, you can also right-click on an item to get the ID.
  4. Or, you can export all items by clicking on the Export task list link.
    Workflow options

Use data from custom fields in template

You can reference the Unique ID in template code to reference the data in the custom field.

Show the value in the field

  1. Open the client context by using the {{#CurrentClient}} {{/CurrentClient}} tags.
  2. In between these tags, use the customfield function and insert the Unique ID between the quotation marks. For example: {{customfield("Newsletter")}}
Code

{{#CurrentClient}}

{{customfield("Newsletter")}}

{{/CurrentClient}}

Test a Yes/No field

Use the following code to show or hide content based on the selection in a Yes/No field.

Code  

{{#CurrentClient}}

{{#isyes(customfield("Newsletter"))}}

Show this text if the answer is Yes in the custom field.

{{/isyes(customfield("Newsletter"))}}

{{/CurrentClient}}

{{#CurrentClient}}

{{#isno(customfield("Newsletter"))}}

Show this text if the answer is No in the custom field.

{{/isno(customfield("Newsletter"))}}

{{/CurrentClient}}