Variables
Last updated
Last updated
Variables allow you to access and manipulate any data from Airdesk. It sounds like a complex concept, but once you learn the basics it is very easy and powerful to use this functionality.
Variables are values referring to various fields in Airdesk, which can be used in many ways, from searching for a certain value in a workspace module, or to writing a personalized email with data from records called in the workflow.
For example the variable {{adn["Task Trigger"]["id"]}} references the Id of the triggered task.
As we add blocks to the canvas, the associated variables will be listed in the variable list available when editing a block. To access the list, we just need to select the gear icon next to the field we want to edit.
When clicked, a pop-up opens with the variables available per module and with the text editor for this field, so that we can search for the variable we want to use.
Using variables can be a simple way to work with automation and get the most out of it. But for that it is necessary to understand how we can use them.
Let's look at the following example:
In this example, we intend to send an email whenever a new Ticket is created. To run this workflow, we need to use a created Ticket trigger, followed by a Create Email action.
After we have the blocks placed on the canvas and linked, we move on to configuring the email. As the first step is the Ticket trigger created, then we can access all the information on the new ticket. These details can be used to edit the email.
In this example, what we want to use is the new ticket number in the email subject. For this, we use the variable {{adn[“Ticket Trigger”][“id”]}} which will return the number of the new record.
The recipient will receive an email with the subject, for example, “New ticket with number 47”.
Using the same workflow, we can also customize the body of the email to give us as much information as possible about the new ticket.
Variables used in the email:
{{adn["Ticket Trigger"]["indirect_client"]?adn["Ticket Trigger"]["indirect_client"]["name"]:adn["Ticket Trigger"]["client"]["name"]}}
If the field "indirect_client" exists, type the name of the "indirect_client", otherwise, type the name of the "client".
{{adn["Ticket Trigger"]["id"]}}
Returns the ID of the ticket created
{{adn["Ticket Trigger"]["name"]}}
Returns the subject of the ticket created
Email received by workflow recipient:
It is also possible with variables to use logical operators in Javascript to create more advanced workflows.
Example:
{{adn["Ticket Trigger"]["indirect_client"]?adn["Ticket Trigger"]["indirect_client"]["name"]:adn["Ticket Trigger"]["client"]["name"]}}
In the example, we can see that between double curly braces, we use a condition in Javascrip to verify if the variable "adn["Ticket Trigger"]["indirect_client"]" exists, the value of the variable will be "adn["Ticket Trigger"]["indirect_client"]["name"]", otherwise the value will be " adn["Ticket Trigger"]["client"]["name"]".
Sintax: variablename = (condition)? value1:value2
To use variables and conditions, we must always enclose them in double braces {{}} and values are always identified by adn["Ticket Trigger"]["indirect_client"].