FOREACH in Planfix: List Products in a Task Description
FOREACH in Planfix lists every value of a multi-value field inside a task description, so a request can show all its products or services without anyone retyping them. A single variable returns one value; when a field holds a whole set — services, assignees, subtasks — you need a construct that prints a line per item. The syntax belongs to text with variables, described in the Help Center article on variables in text. This three-minute video shows how to build that list with a dynamic block.
What you’ll learn: how to list repeating values with FOREACH
- Recognize which fields hold several values and give a repeating variable.
- Add a dynamic block and set its result type to Text with variables.
- Write the FOREACH construct, choose a delimiter and print one line per value.
- Narrow the list with a condition, or switch to TABLE for columns and totals.
How to list products in a task description in Planfix, step by step
Step 1. Pick a field that holds a set of values
FOREACH only makes sense for a field that can hold more than one value. Planfix calls these repeating, or multiplying, variables: assignees, participants, auditors, attached files and data tags among system fields, plus custom fields such as List, Task set, Directory values set and Users list. On its own, such a variable prints all values in one comma-separated line — FOREACH is what gives you control over the layout.
Step 2. Add a dynamic block to the description
Dynamic blocks sit in a task description and are recalculated every time the task is opened. Add one while creating or editing a task; a dynamic block also works in a task template and in a custom field of type multi-line text, as long as the Use text editor option is enabled. Click the three dots in curly brackets to add a variable or formula, and choose Text with variables as the type of result — the type that accepts all the constructs and lets you format the output.
Step 3. Write the FOREACH construct
Inside the block, type two percent signs to open the auto-fill window and pick the construct. The pattern is %%$FOREACH(Variable;Delimiter)$%%, the text to repeat, then %%$ENDBLOCK$%%. The first argument must be the first-level variable — the field you iterate over, such as {{Task.Assignee}} or {{Task.Subtasks}}, and nothing else. Inside the body, name the variable again and point to the field whose data should be printed. The delimiter separates the values: pass <br> and each value starts on its own line.
A finished line follows the pattern from the Help Center: %%$FOREACH({{Task.Subtasks}};”<br>”)$%%{{Task.Subtasks.Number}} – {{Task.Subtasks.Name}}%%$ENDBLOCK$%% prints the number and the name of every subtask, one per row.
Step 4. Add a condition or build a table
FOREACH takes an optional third argument — a condition written without IF, as in %%$FOREACH(Variable;Delimiter;Condition)$%%. With it, a list of subtasks shows only those above a contract-amount threshold. When the list needs columns rather than lines, use TABLE: draw the table with the Planfix editor and pass the number of header and total rows, as in %%$TABLE({{Data tag.Service}};1;1)$%% — one for the header, one for the totals. If the result belongs in a field of its own, Planfix also has calculated fields with formulas.
Step 5. Save the block and open the task
Save the block, and the data is recalculated each time the task is opened, so the list always reflects the field’s current contents. One detail is easy to miss: a dynamic block always starts on a new line. To keep a label and the result on one line, put the text inside the block.
Example: a request that lists its own services
The example in the video is a request whose description lists the products or services it covers instead of having them copied in by hand. The Help Center documents the same pattern with a data tag: each service is added as a data tag record, a TABLE construct prints the service name and amount for every record, and a SUM formula adds up the order total. Because data tags store structured records inside a task, the list and its total match what was actually added.
Who it’s for
- Sales: a request or proposal that lists the ordered items with their prices, ready to be sent on.
- Finance and management: service lines and their total shown next to the records they come from.
- Support and service teams: every item of a request visible the moment the task is opened.
- Project managers: a parent task that prints its subtasks with numbers, names and assignees.
- Administrators: one construct in a template instead of an instruction to copy by hand.
FAQ
How do I show all values of a multi-value field in a task description?
Add a dynamic block, set its type of result to Text with variables, and wrap the field in a FOREACH construct with a delimiter. Without FOREACH, a repeating variable prints all values in one comma-separated line.
What is the difference between FOREACH and TABLE in Planfix?
FOREACH repeats a piece of text for each value, separated by the delimiter you choose. TABLE repeats the rows of a table drawn in the Planfix editor and can reserve rows for a header and totals.
Can I list only some values of a field?
Yes. FOREACH accepts a third argument — a condition written without IF — so only matching values are printed. A nested IF block handles more complex rules.
Start with one list you still retype
Pick one request where somebody still copies products or services into the description by hand, and replace that paragraph with a FOREACH construct in a dynamic block. From there it joins the rest of business process automation in Planfix: templates, scripts and buttons that fill in data instead of asking for it. For more on the block itself, see dynamic blocks in a task description. New to Planfix? Sign up to try it.
