Variables in Text: Difference between revisions

From Planfix
Jump to: navigation, search
No edit summary
 
(12 intermediate revisions by 2 users not shown)
Line 7: Line 7:


<div style="background:#ffbaba;padding:10px;border:1px solid #ff9b9b;">This help article does not apply to document templates. Read how to use variables in document templates [[Variables in document templates|here]].</div>
<div style="background:#ffbaba;padding:10px;border:1px solid #ff9b9b;">This help article does not apply to document templates. Read how to use variables in document templates [[Variables in document templates|here]].</div>
== Navigation ==
== Navigation ==
*[[#Calculations with variables|Calculations with variables]]
*[[#Calculations with variables|Calculations with variables]]
Line 17: Line 15:
*[[#TABLE|TABLE]]
*[[#TABLE|TABLE]]
*[[#FOREACH and TABLE with infoblocks|FOREACH and TABLE with infoblocks]]
*[[#FOREACH and TABLE with infoblocks|FOREACH and TABLE with infoblocks]]


Variables store some value, such as a number, string, or other data type. Variables are used in:
Variables store some value, such as a number, string, or other data type. Variables are used in:
Line 37: Line 34:
To add a variable to the text, for example, in the task description, click on the "different variables" link (1), create the variable, and add it to the text of the desired field in the task template (2):
To add a variable to the text, for example, in the task description, click on the "different variables" link (1), create the variable, and add it to the text of the desired field in the task template (2):
   
   
https://s.pfx.so/pf/6j/W61WdH.jpg
https://s.pfx.so/pf/ip/pXIpIc.jpg
 
 
== '''Calculations with Variables''' ==
== '''Calculations with Variables''' ==
Sometimes, it is not enough to insert the value of a variable into the text, and you also need to do calculations with the values in the variables or process the string you get. For such actions, you use the following syntax:
Sometimes, it is not enough to insert the value of a variable into the text, and you also need to do calculations with the values in the variables or process the string you get. For such actions, you use the following syntax:


  %%%'''FORMULA TEXT'''%%%
  %%%'''FORMULA TEXT'''%%%
=== Examples ===
=== Examples ===
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;"><nowiki>Discounted price: %%%{{Task.Price}}*0.8%%%</nowiki></div>
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;"><nowiki>Discounted price: %%%{{Task.Price}}*0.8%%%</nowiki></div>


<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;"><nowiki>Work will be completed in %%%DATEDIF(NOW(); {{Task.Completion Date}}; "d")%%% %%%MULTIPLE(DATEDIF(NOW(); {{Task.Completion Date}}; "d");"day"; "days")%%%</nowiki></div>
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;"><nowiki>Work will be completed in %%%DATEDIF(NOW(); {{Task.Completion Date}}; "d")%%% %%%MULTIPLE(DATEDIF(NOW(); {{Task.Completion Date}}; "d");"day"; "days")%%%</nowiki></div>
=== Important ===
=== Important ===
*The formula text must be written in one string and cannot be broken. In other words, the formula cannot be broken to the next string by pressing the Enter key.
*The formula text must be written in one string and cannot be broken. In other words, the formula cannot be broken to the next string by pressing the Enter key.
*Variables in the formula cannot be formatted, for example, changing it to bold or making it cursive.
*Variables in the formula cannot be formatted, for example, changing it to bold or making it cursive.
*If you need to highlight the result of the formula in bold, apply the formatting to the entire formula along with the result.
*If you need to highlight the result of the formula in bold, apply the formatting to the entire formula along with the result.
== '''IF''' ==
== '''IF''' ==
To insert text depending on the values of variables (conditions), use the following syntax:
To insert text depending on the values of variables (conditions), use the following syntax:
Line 65: Line 55:
'''The expression must be added in one string without spaces and line breaks:'''
'''The expression must be added in one string without spaces and line breaks:'''
%%$IF(Logical formula)$%%TEXT%%$ENDBLOCK$%%</div>
%%$IF(Logical formula)$%%TEXT%%$ENDBLOCK$%%</div>
=== Example ===
=== Example ===
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">
Line 71: Line 60:
VIP CUSTOMER<br>
VIP CUSTOMER<br>
%%$ENDBLOCK$%%
%%$ENDBLOCK$%%


'''Result''':
'''Result''':


VIP CUSTOMER</div>
VIP CUSTOMER</div>
== '''ELSE''' ==
== '''ELSE''' ==
'''ELSE''' is used only together with IF. When the condition in IF is not true, the text from the ELSE part of the block is displayed.
'''ELSE''' is used only together with IF. When the condition in IF is not true, the text from the ELSE part of the block is displayed.
Line 92: Line 79:
%%$IF(Logical formula)$%%TEXT%%$ ELSE$%%TEXT%%$ENDBLOCK$%%
%%$IF(Logical formula)$%%TEXT%%$ ELSE$%%TEXT%%$ENDBLOCK$%%
</div>
</div>
=== Example ===
=== Example ===
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">
%%$<span style="color:green">IF</span>(<span style="color:blue"><nowiki>{{Task.Invoice Number}}=""</nowiki></span>)$%%<br>
%%$<span style="color:green">IF</span>(<span style="color:blue"><nowiki>{{Task. Invoice }}=""</nowiki></span>)$%%<br>
<pan style="color:red">The field [Invoice Number] is not filled in</span><br>
<span style="color:red">The field [Invoice ] is not filled in</span><br>  
%%$<span style="color:#ef18c7">ELSE</span>$%%<br>
%%$<span style="color:#ef18c7">ELSE</span>$%%<br>
<span style="color:red">The required task field is filled in! :)</span><br>
<span style="color:red">The required task field is filled in! :)</span><br>  
%%$<span style="color:green">ENDBLOCK</span>$%%
%%$<span style="color:green">ENDBLOCK</span>$%%


'''Result''':
'''Result''':
Line 107: Line 92:
*If the field is filled in, the message "The required task field is filled in! :)" will be displayed.
*If the field is filled in, the message "The required task field is filled in! :)" will be displayed.
</div>
</div>
== '''ELSEIF''' ==
== '''ELSEIF''' ==
Helps create a more complex expression with conditions:
Helps create a more complex expression with conditions:
Line 129: Line 112:
'''The construction must be added in one line without spaces and line breaks''':
'''The construction must be added in one line without spaces and line breaks''':
:%%$IF(Logical formula)$%%TEXT%%$ELSEIF(Logical formula)$%%TEXT%%$ELSEIF(Logical formula)$%%TEXT%%$ ELSE$%%TEXT%%$ENDBLOCK$%%
:%%$IF(Logical formula)$%%TEXT%%$ELSEIF(Logical formula)$%%TEXT%%$ELSEIF(Logical formula)$%%TEXT%%$ ELSE$%%TEXT%%$ENDBLOCK$%%
=== Example ===
=== Example ===
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">
Line 141: Line 123:
<span style="color:red">All task fields are filled in, you're awesome! :)</span><br>
<span style="color:red">All task fields are filled in, you're awesome! :)</span><br>
%%$<span style="color:green">ENDBLOCK</span>$%%
%%$<span style="color:green">ENDBLOCK</span>$%%


'''Result''':
'''Result''':
Line 147: Line 128:
*If all three fields are not filled in, only the first message "The field [Invoice Number] is not filled in" will be displayed, the rest will be skipped.
*If all three fields are not filled in, only the first message "The field [Invoice Number] is not filled in" will be displayed, the rest will be skipped.
*If the fields "Invoice Number" and "UPD Number" are filled in, but the field "Contract Number" is not, then the corresponding message "The field [Contract Number] is not filled in" will be displayed.</div>
*If the fields "Invoice Number" and "UPD Number" are filled in, but the field "Contract Number" is not, then the corresponding message "The field [Contract Number] is not filled in" will be displayed.</div>
== '''FOREACH''' ==
== '''FOREACH''' ==
When a variable represents a list of values, such as <nowiki>{{Task.Subtasks}}</nowiki> or <nowiki>{{Task.Assignee}}</nowiki>, and you need to display information for each value, use the following syntax:
When a variable represents a list of values, such as <nowiki>{{Task.Subtasks}}</nowiki> or <nowiki>{{Task.Assignee}}</nowiki>, and you need to display information for each value, use the following syntax:


<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">%%$<span style="color:green;">FOREACH(<span style="color:blue;">Variable</span>;<span style="color:blue;">Delimiter</span>)</span>$%%<br>'''<span style="color:red;">TEXT</span>'''<br>%%$<span style="color:green;">ENDBLOCK</span>$%%
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">%%$<span style="color:green;">FOREACH(<span style="color:blue;">Variable</span>;<span style="color:blue;">Delimiter</span>)</span>$%%<br>'''<span style="color:red;">TEXT</span>'''<br>%%$<span style="color:green;">ENDBLOCK</span>$%%


'''Important''': in this part of the expression — %%$<span style="color:green;">FOREACH(<span style="color:blue;">Variable</span>;<span style="color:blue;">Delimiter</span>)</span>$%% — be sure to specify the first-level variable, i.e. <nowiki>{{Task.Subtasks}}</nowiki> or <nowiki>{{Task.Assignee}}</nowiki>, and nothing else.</div>
'''Important''': in this part of the expression — %%$<span style="color:green;">FOREACH(<span style="color:blue;">Variable</span>;<span style="color:blue;">Delimiter</span>)</span>$%% — be sure to specify the first-level variable, i.e. <nowiki>{{Task.Subtasks}}</nowiki> or <nowiki>{{Task.Assignee}}</nowiki>, and nothing else.</div>


'''The expression must be added in one string without spaces and line breaks:'''
'''The expression must be added in one string without spaces and line breaks:'''
%%$FOREACH(Variable;Delimiter)$%%TEXT%%$ENDBLOCK$%%
%%$FOREACH(Variable;Delimiter)$%%TEXT%%$ENDBLOCK$%%
=== Example ===
=== Example ===
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;"><nowiki>%%$FOREACH({{Task.Assignee}};"<br>")$%%</nowiki><nowiki>{{Task.Assignee}} - {{Task.Assignee.Position}}</nowiki>%%$ENDBLOCK$%%
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;"><nowiki>%%$FOREACH({{Task.Assignee}};"<br>")$%%</nowiki><nowiki>{{Task.Assignee}} - {{Task.Assignee.Position}}</nowiki>%%$ENDBLOCK$%%


'''Result''':
'''Result''':
Line 171: Line 145:


<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;"><nowiki>%%$FOREACH({{Task.Subtasks}};"<br>")$%%</nowiki><nowiki>{{Task.Subtasks.Number}} - {{Task.Subtasks.Name}}</nowiki>%%$ENDBLOCK$%%
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;"><nowiki>%%$FOREACH({{Task.Subtasks}};"<br>")$%%</nowiki><nowiki>{{Task.Subtasks.Number}} - {{Task.Subtasks.Name}}</nowiki>%%$ENDBLOCK$%%


'''Result''':
'''Result''':


2119 - Rough finish<br>2120 - Sub-final finishing<br>2121 - Final touches</div>
2119 - Rough finish<br>2120 - Sub-final finishing<br>2121 - Final touches</div>
=== Example with condition ===
=== Example with condition ===
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">'''Syntax:'''
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">'''Syntax:'''


%%$<span style="color:green;">FOREACH(<span  
%%$<span style="color:green;">FOREACH(<span  
Line 187: Line 157:
style="color:blue;">Condition_WITHOUT_If</span>)</span>$%%<br>  '''<span style="color:red;">TEXT</span>'''<br>%%$<span  
style="color:blue;">Condition_WITHOUT_If</span>)</span>$%%<br>  '''<span style="color:red;">TEXT</span>'''<br>%%$<span  
style="color:green;">ENDBLOCK</span>$%%
style="color:green;">ENDBLOCK</span>$%%


%%$FOREACH(<nowiki>{{Task.Subtasks}}</nowiki>;"";<nowiki>{{Task.Subtasks."Contract Amount ($)"}}</nowiki>>1000))$%%<br>
%%$FOREACH(<nowiki>{{Task.Subtasks}}</nowiki>;"";<nowiki>{{Task.Subtasks."Contract Amount ($)"}}</nowiki>>1000))$%%<br>
<nowiki>{{Task.Subtasks.Counterparty}}, contract amount {{Task.Subtasks."Contract Amount ($)"}}</nowiki><br>
<nowiki>{{Task.Subtasks.Counterparty}}, contract amount {{Task.Subtasks."Contract Amount ($)"}}</nowiki><br>
%%$ENDBLOCK$%%
%%$ENDBLOCK$%%


'''Result'''
'''Result'''
Line 198: Line 166:
From the entire list of counterparties, only those with a contract amount of more than 1000 will be displayed:
From the entire list of counterparties, only those with a contract amount of more than 1000 will be displayed:


OOO LLC Sunrise, 1500<br>
LLC Sunrise, 1500<br>


OOO LLC Sunset, 1700<br>
LLC Sunset, 1700<br>


OOO Dawn, 2500<br>
LLC Dawn, 2500<br>


</div>
</div>
=== ELSE block inside FOREACH block ===
=== ELSE block inside FOREACH block ===
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">'''Syntax:'''
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">'''Syntax:'''


%%$<span style="color:green;">FOREACH(<span style="color:blue;">Variable</span>;<span style="color:blue;">Delimiter</span>)</span>$%%<br>  '''<span style="color:red;">TEXT</span>'''<br>  %%$<span style="color:green;">IF(</span><span style="color:blue;">Logical formula</span><span style="color:green;">)</span>$%%<br>    <span style="color:red;">TEXT</span><br>  %%$<span style="color:green;">ENDBLOCK</span>$%%<br>  '''<span style="color:red;">TEXT</span>'''<br>%%$<span style="color:green;">ENDBLOCK</span>$%%
%%$<span style="color:green;">FOREACH(<span style="color:blue;">Variable</span>;<span style="color:blue;">Delimiter</span>)</span>$%%<br>  '''<span style="color:red;">TEXT</span>'''<br>  %%$<span style="color:green;">IF(</span><span style="color:blue;">Logical formula</span><span style="color:green;">)</span>$%%<br>    <span style="color:red;">TEXT</span><br>  %%$<span style="color:green;">ENDBLOCK</span>$%%<br>  '''<span style="color:red;">TEXT</span>'''<br>%%$<span style="color:green;">ENDBLOCK</span>$%%


%%$FOREACH(<nowiki>{{Task.Subtasks}}</nowiki>)$%%%%$IF(<nowiki>{{Task.Subtasks.Status}}</nowiki>="TKP added to calculation")$%%<br>
%%$FOREACH(<nowiki>{{Task.Subtasks}}</nowiki>)$%%%%$IF(<nowiki>{{Task.Subtasks.Status}}</nowiki>="TKP added to calculation")$%%<br>
<nowiki>{{Task.Subtasks.Counterparty}}, {{Task.Subtasks.Counterparty.TIN}}, contract amount {{Task.Subtasks."Contract Amount"}} {{Task.Subtasks.Currency.Symbol}}</nowiki><br>
<nowiki>{{Task.Subtasks.Counterparty}}, {{Task.Subtasks.Counterparty.TIN}}, contract amount {{Task.Subtasks."Contract Amount"}} {{Task.Subtasks.Currency.Symbol}}</nowiki><br>
%%$ENDBLOCK$%%%%$ENDBLOCK$%%
%%$ENDBLOCK$%%%%$ENDBLOCK$%%


'''Result''':
'''Result''':
Line 225: Line 189:
LLC Light, 5689845235689, 500 $
LLC Light, 5689845235689, 500 $
</div>
</div>
== '''TABLE''' ==
== '''TABLE''' ==
If a variable represents a list of values, and you need to display the information for each value in the form of a table, use the following syntax:
If a variable represents a list of values, and you need to display the information for each value in the form of a table, use the following syntax:


<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">%%$<span style="color:green;">TABLE(<span style="color:blue;">Variable</span>)</span>$%%<br>'''<span style="color:red;">TEXT</span>'''<br>%%$<span style="color:green;">ENDBLOCK</span>$%%</div>
<div style="display: block; padding: 1em; margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: black; word-wrap: break-word; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;">%%$<span style="color:green;">TABLE(<span style="color:blue;">Variable</span>)</span>$%%<br>'''<span style="color:red;">TEXT</span>'''<br>%%$<span style="color:green;">ENDBLOCK</span>$%%</div>
 
== Example ==
== Example ===
The example shows how to extract only the necessary blocks from the added data tag in the task and send this information to the customer as a table. The table is added using the Planfix editor:  
The example shows how to extract only the necessary blocks from the added data tag in the task and send this information to the customer as a table. The table is added using the Planfix editor:  


Line 244: Line 205:
|}
|}
%%$ENDBLOCK$%%
%%$ENDBLOCK$%%


Total order amount:
Total order amount:
<nowiki>%%%TEXT(SUM({{Data tag.Service.Amount}});",.2f")+MULTIPLE(SUM({{Data tag.Service.Amount}}); " ruble"; " rubles")%%%</nowiki>
<nowiki>%%%TEXT(SUM({{Data tag.Service.Amount}});",.2f")+MULTIPLE(SUM({{Data tag.Service.Amount}}); " ruble"; " rubles")%%%</nowiki>


'''Result:'''
'''Result:'''
Line 267: Line 226:


</div>
</div>
=== Example with header and total ===
=== Example with header and total ===
To add a header or a totals row to the table, use the following parameters in the syntax:
To add a header or a totals row to the table, use the following parameters in the syntax:
Line 278: Line 234:


'''Example:'''
'''Example:'''
%%$TABLE(<nowiki>{{Data Tag.Service}}</nowiki>;0;0)$%%<br>
%%$TABLE(<nowiki>{{Data Tag.Service}}</nowiki>;<span style="color:red;">1</span>;<span style="color:red;">1</span>)$%%<br>
{| class="wikitable"
{| class="wikitable"
! #
! #
Line 332: Line 288:


'''Example:'''
'''Example:'''
 
%%$TABLE(<nowiki>{{Data tag .Service}}</nowiki>;<span style="color:red;">2</span>;<span style="color:red;">1</span>)$%%<br>
%%$TABLE(<nowiki>{{Data tag .Service}}</nowiki>;2;1)$%%<br>
{| class="wikitable"
{| class="wikitable"
!colspan="3"|Set of services
!colspan="3"|Set of services
Line 342: Line 297:
|-
|-
|<nowiki>{{Data tag.Service.Record Number}}</nowiki>
|<nowiki>{{Data tag.Service.Record Number}}</nowiki>
|<nowiki>{{data tag.Service.Service Name}}</nowiki>
|<nowiki>{{Data tag.Service.Service Name}}</nowiki>
|<nowiki>{{Data tag.Service.Amount}}</nowiki>
|<nowiki>{{Data tag.Service.Amount}}</nowiki>
|-
|-
Line 381: Line 336:
|}
|}
</div>
</div>


=== Example with condition ===
=== Example with condition ===
Line 431: Line 385:
To add a header to the table, right-click on it and select '''Row''' - '''Insert Row Above''':
To add a header to the table, right-click on it and select '''Row''' - '''Insert Row Above''':


https://s.pfx.so/pf/PW/0gj3Yt.jpg
https://s.pfx.so/pf/NB/mTnMq2.jpg
 
== Important ==
== Important ==
In TABLES at the moment, nesting of constructions is not supported, thus the IF block inside the TABLE will not work. A temporary solution is to use the TABLE block with the IF function, that is, instead of the "%%'''$'''IF" block, use the function "%%%IF".
In TABLES at the moment, nesting of constructions is not supported, thus the IF block inside the TABLE will not work. A temporary solution is to use the TABLE block with the IF function, that is, instead of the "%%'''$'''IF" block, use the function "%%%IF".
Line 454: Line 407:
%%$TABLE(<nowiki>{{Infoblock.!line}}</nowiki>)$%%
%%$TABLE(<nowiki>{{Infoblock.!line}}</nowiki>)$%%
{| class="wikitable"
{| class="wikitable"
|<nowiki>{{Infoblock.!line.Product}}</nowiki>
|<nowiki>{{Infoblock.!string.Product}}</nowiki>
|<nowiki>{{Infoblock.!line.Price}}</nowiki>
|<nowiki>{{Infoblock.!string.Price}}</nowiki>
|}
|}
%%$ENDBLOCK$%%
%%$ENDBLOCK$%%


'''Result''':
'''Result''':
Line 471: Line 423:
|10,00
|10,00
|-
|-
|}
</div>
</div>


Line 476: Line 429:
== Go To ==
== Go To ==
*[[Variables in task templates]]
*[[Variables in task templates]]
*[[Variables in document templates]]]
*[[Variables in document templates]]

Latest revision as of 12:45, 5 November 2024

This help article does not apply to document templates. Read how to use variables in document templates here.

Navigation

Variables store some value, such as a number, string, or other data type. Variables are used in:

  • Task name (in task template or when creating a task)
  • Task description (in task template or when creating a task)
  • Email templates
  • Script actions, buttons, incoming webhooks, email rules for tasks:
    • Send HTTP request
    • Send SMS
    • Write to WhatsApp
    • Write to Instagram
  • Bulk actions, scripts, buttons, incoming webhooks, email rules for tasks:
    • Change name
    • Change description
    • Add comment
    • Set field value (for "Text" fields)


To add a variable to the text, for example, in the task description, click on the "different variables" link (1), create the variable, and add it to the text of the desired field in the task template (2):

pXIpIc.jpg

Calculations with Variables

Sometimes, it is not enough to insert the value of a variable into the text, and you also need to do calculations with the values in the variables or process the string you get. For such actions, you use the following syntax:

%%%FORMULA TEXT%%%

Examples

Discounted price: %%%{{Task.Price}}*0.8%%%
Work will be completed in %%%DATEDIF(NOW(); {{Task.Completion Date}}; "d")%%% %%%MULTIPLE(DATEDIF(NOW(); {{Task.Completion Date}}; "d");"day"; "days")%%%

Important

  • The formula text must be written in one string and cannot be broken. In other words, the formula cannot be broken to the next string by pressing the Enter key.
  • Variables in the formula cannot be formatted, for example, changing it to bold or making it cursive.
  • If you need to highlight the result of the formula in bold, apply the formatting to the entire formula along with the result.

IF

To insert text depending on the values of variables (conditions), use the following syntax:

%%$IF(Logical formula)$%%
TEXT
%%$ENDBLOCK$%%

The expression must be added in one string without spaces and line breaks:

%%$IF(Logical formula)$%%TEXT%%$ENDBLOCK$%%

Example

%%$IF({{Task.Order Amount}} > 100000)$%%
VIP CUSTOMER
%%$ENDBLOCK$%%

Result:

VIP CUSTOMER

ELSE

ELSE is used only together with IF. When the condition in IF is not true, the text from the ELSE part of the block is displayed.

%%$IF(Logical formula)$%%
TEXT
%%$ELSE$%%
TEXT
%%$ENDBLOCK$%%

The construction must be added in one line without spaces and line breaks:

%%$IF(Logical formula)$%%TEXT%%$ ELSE$%%TEXT%%$ENDBLOCK$%%

Example

%%$IF({{Task. Invoice №}}="")$%%
The field [Invoice №] is not filled in
%%$ELSE$%%
The required task field is filled in! :)
%%$ENDBLOCK$%%

Result:

  • If the field is not filled in, the message "The field [Invoice №] is not filled in" will be displayed.
  • If the field is filled in, the message "The required task field is filled in! :)" will be displayed.

ELSEIF

Helps create a more complex expression with conditions:

%%$IF(Logical formula)$%%
TEXT
%%$ELSEIF(Logical formula)$%%
TEXT
%%$ELSEIF(Logical formula)$%%
TEXT
%%$ELSE$%%
TEXT
%%$ENDBLOCK$%%


Note

  • The last ELSE is an optional part of the block.

The construction must be added in one line without spaces and line breaks:

%%$IF(Logical formula)$%%TEXT%%$ELSEIF(Logical formula)$%%TEXT%%$ELSEIF(Logical formula)$%%TEXT%%$ ELSE$%%TEXT%%$ENDBLOCK$%%

Example

%%$IF({{Task.Invoice Number}}="")$%%
The field [Invoice Number] is not filled in
%%$ELSEIF({{Task.UPD Number}}="")$%%
The field [UPD Number] is not filled in
%%$ELSEIF({{Task.Contract Number}}="")$%%
The field [Contract Number] is not filled in
%%$ELSE$%%
All task fields are filled in, you're awesome! :)
%%$ENDBLOCK$%%

Result:

  • If all three fields are not filled in, only the first message "The field [Invoice Number] is not filled in" will be displayed, the rest will be skipped.
  • If the fields "Invoice Number" and "UPD Number" are filled in, but the field "Contract Number" is not, then the corresponding message "The field [Contract Number] is not filled in" will be displayed.

FOREACH

When a variable represents a list of values, such as {{Task.Subtasks}} or {{Task.Assignee}}, and you need to display information for each value, use the following syntax:

%%$FOREACH(Variable;Delimiter)$%%
TEXT
%%$ENDBLOCK$%% Important: in this part of the expression — %%$FOREACH(Variable;Delimiter)$%% — be sure to specify the first-level variable, i.e. {{Task.Subtasks}} or {{Task.Assignee}}, and nothing else.

The expression must be added in one string without spaces and line breaks: %%$FOREACH(Variable;Delimiter)$%%TEXT%%$ENDBLOCK$%%

Example

%%$FOREACH({{Task.Assignee}};"<br>")$%%{{Task.Assignee}} - {{Task.Assignee.Position}}%%$ENDBLOCK$%%

Result:

linda Martinez - Designer
Jamse Davis - Developer
Mary Brown - CEO
%%$FOREACH({{Task.Subtasks}};"<br>")$%%{{Task.Subtasks.Number}} - {{Task.Subtasks.Name}}%%$ENDBLOCK$%%

Result:

2119 - Rough finish
2120 - Sub-final finishing
2121 - Final touches

Example with condition

Syntax:

%%$FOREACH(Variable;Delimiter;Condition_WITHOUT_If)$%%
TEXT
%%$ENDBLOCK$%%

%%$FOREACH({{Task.Subtasks}};"";{{Task.Subtasks."Contract Amount ($)"}}>1000))$%%
{{Task.Subtasks.Counterparty}}, contract amount {{Task.Subtasks."Contract Amount ($)"}}
%%$ENDBLOCK$%%

Result

From the entire list of counterparties, only those with a contract amount of more than 1000 will be displayed:

LLC Sunrise, 1500

LLC Sunset, 1700

LLC Dawn, 2500

ELSE block inside FOREACH block

Syntax:

%%$FOREACH(Variable;Delimiter)$%%
TEXT
 %%$IF(Logical formula)$%%
TEXT
 %%$ENDBLOCK$%%
TEXT
%%$ENDBLOCK$%%

%%$FOREACH({{Task.Subtasks}})$%%%%$IF({{Task.Subtasks.Status}}="TKP added to calculation")$%%
{{Task.Subtasks.Counterparty}}, {{Task.Subtasks.Counterparty.TIN}}, contract amount {{Task.Subtasks."Contract Amount"}} {{Task.Subtasks.Currency.Symbol}}
%%$ENDBLOCK$%%%%$ENDBLOCK$%%

Result:

LLC Sunrise, 5689845987654, 1500 $
LLC Sunset, 5689845125699, 1700 $
LLC Dawn, 5689845589674, 2500 $
LLC Light, 5689845235689, 500 $

TABLE

If a variable represents a list of values, and you need to display the information for each value in the form of a table, use the following syntax:

%%$TABLE(Variable)$%%
TEXT
%%$ENDBLOCK$%%

Example

The example shows how to extract only the necessary blocks from the added data tag in the task and send this information to the customer as a table. The table is added using the Planfix editor:

Order №{{Task.Number}}

%%$TABLE({{Data tag.Service}})$%%

{{Data tag.Service.Service Name}} {{Data tag.Service.Amount}}

%%$ENDBLOCK$%%

Total order amount: %%%TEXT(SUM({{Data tag.Service.Amount}});",.2f")+MULTIPLE(SUM({{Data tag.Service.Amount}}); " ruble"; " rubles")%%%

Result:

Order №2118

Graphic design 1 600.00
Programming 3 000.00
Development of TA 300.00

Total order amount: 4 900.00 dollars

Example with header and total

To add a header or a totals row to the table, use the following parameters in the syntax:

%%$TABLE(Variable;0;0)$%%
Table drawn using the Planfix editor
%%$ENDBLOCK$%%

Example: %%$TABLE({{Data Tag.Service}};1;1)$%%

# Name Price
{{Data tag.Service.Record Number}} {{Data tag.Service.Service Name}} {{Data tag.Service.Amount}}
Total %%%SUM({{Data tag.Service.Amount}})%%%

%%$ENDBLOCK$%%


Result:

# Name Price
1 Development of TA 1 000.00
2 Programming 3 705.00
3 Graphic design 1 035.00
4 Testing 690.00
Total 6430

The numbers highlighted in red indicate how many rows to use in the header and totals.

For example, the numbers (1;1) in the above example mean that one row at the beginning will be used for the table header and one row at the end will be used for the table totals.

To use two rows in the table header, specify it like this — (2;1).

Example: %%$TABLE({{Data tag .Service}};2;1)$%%

Set of services
# Name Price
{{Data tag.Service.Record Number}} {{Data tag.Service.Service Name}} {{Data tag.Service.Amount}}
Total %%%SUM({{Data tag.Service.Amount}})%%%

%%$ENDBLOCK$%%


Result:

Set of services
# Name Price
1 Development of TA 1 000.00
2 Programming 3 705.00
3 Graphic design 1 035.00
4 Testing 690.00
Total 6430

Example with condition

%%$TABLE(Variable;0;0;Condition_WITHOUT_If)$%%
Table drawn using the Planfix editor
%%$ENDBLOCK$%%


%%$TABLE({{Task.Subtasks}};1;0;{{Task.Subtasks.Status}}="TKP added to calculation")$%%

Counterparty TIN Contract amount
{{Task.Subtasks.Counterparty}} {{Task.Subtasks.Counterparty.TIN}} {{Task.Subtasks."Contract Amount"}}{{Task.Subtasks.Currency.Symbol}}

%%$ENDBLOCK$%%


Result:

Counterparty TIN Contract amount
LLC Sunrise 5689845987654 1500$
LLC Sunset 5689845125699 1700$
LLC Dawn 5689845589674 2500$
LLC Light 5689845235689 500$


To add a header to the table, right-click on it and select Row - Insert Row Above:

mTnMq2.jpg

Important

In TABLES at the moment, nesting of constructions is not supported, thus the IF block inside the TABLE will not work. A temporary solution is to use the TABLE block with the IF function, that is, instead of the "%%$IF" block, use the function "%%%IF".

FOREACH and TABLE with infoblocks

When parsing an email or responding to an HTTP request, you receive several lines of data and want to add them in the form of structured text or a table:

%%$FOREACH({{Infoblock.!line}};Separator)$%%
{{Infoblock.!line.Infoblock name}}
%%$ENDBLOCK$%%

%%$TABLE({{Infoblock.!line}})$%%
{{Infoblock.!line.Infoblock name}}
%%$ENDBLOCK$%%


Example

Let's extract data into the "Product" and "Price" infoblocks and add them to the table:

%%$TABLE({{Infoblock.!line}})$%%

{{Infoblock.!string.Product}} {{Infoblock.!string.Price}}

%%$ENDBLOCK$%%

Result:

Pencil 1,00
Pen 2,00
Notebook 10,00


Go To