Repeating variables

From Planfix
Jump to: navigation, search

Repeating (multiplying) variables are used with fields that can contain multiple values (such as assignees, files, etc.). They allow you to automatically output data from these fields into document templates, text with variables, and calculated fields – either by generating a separate row for each value or by combining all values into a single comma-separated line. Fields that can contain sets of values in tasks, contacts, projects, and employees include:

System fields

Field Variable
Assignees {{Task.Assignee}}
Participants {{Task.Participant}}
Auditors {Task.Task auditors}}
Data tag {{Data tag.Actual working time}}
Files {{{Task.Attached files}}

{{Task.Task file}}
{{Task.All files of the task}}

Custom fields

Custom Fields

  • List
  • Task set
  • Directory values set
  • Users list
  • Values set
  • Files

Output all values in one row

If you use a repeating variable in a Word template or in text with variables, all values from the field will be listed in a single line, separated by commas. Here’s what the variable looks like in the template:

X8QVqZ.png

In the generated document:

Iv6sWO.png

Output values on separate rows

In Excel templates or in Word tables, repeating variables automatically duplicate rows and output every value included in the field.

Here’s what the variable looks like in the template:

ComkgY.png

In the generated document:

fT6xSe.png

Additional options

For more advanced formatting in text with variables, you can use the FOREACH or TABLE constructs.

For example, using FOREACH with a repeating variable in a dynamic block:

Q3JNJU.png

After saving the block, the data will be displayed as a column:

b67SQL.png

Important

  • In the FOREACH and TABLE constructs, the first argument must be the field name you want to iterate over:

SKkY8R.png

  • Inside the body of each construct, you must add the variable name and specify which field the data should be taken from:

VpAqFg.png

Variables and JSON in POST Requests

For a JSON-formatted request, a repeating variable is represented as an array:

H2VJgq.png

The request will generate valid JSON:

{
	phone: [
		"1 (234) 567-89-01",
		"2 (345) 678-91-23",
		"+5 (6789) 12-34-56"
	]
}


If the endpoint expects a single string instead of an array, use the “Phones as a string” variable:

{
    phone: "{{Task.Counterparty.Phones as string}}"
}


Result:

{
	phone: "1 (234) 567-89-01,2 (345) 678-91-23,+5 (6789) 12-34-56"
}


Go To