The expert mode allows to access more settings and create even more advanced workflows, but at the cost of an increased complexity. To enable the expert mode, just flip the switch at the bottom of the page in the modeler. The next element selected will then appear with the additional options and parameters.


Warning: the expert mode allows to build much more advanced workflows, but also makes it possible to set incorrect parameter or settings and thus to deploy workflows that will crash when running an instance. It is highly recommended to test your workflows before making them available to the end users.



Variables


The second thing the expert mode enables is to use variables. A variable is a named entity and containing a data value. When a variable is used, it is substituted by its value. Variables allow leveraging the values entered by users in forms to make workflows even more advanced and dynamic.



1 - Reference to a variable


To substitute a variable's value, write a dollar sign followed by the name of the variable in braces. For instance: 


${computer_need}


is a valid reference to the variable “computer_need”.



2 - Reference to a metadata


Metadata values can be referenced in a similar way by calling the function “getAttributeValueByName” on the predefined variable “pt4d_file”. For instance :

${pt4d_file.getAttributeValueByName('4 - Invoice date')}


is a reference to the metadata “4 - Invoice date”.



3 - Operators


Operations and tests can be performed on the workflow variables. Below is the list of available operators.


Operator

Description

Examples

+

Addition

${value_a + value_b}

${value_a + 100}

-

Subtraction or negative value

${value_a - value_b}

${value_a - 100}

*

Multiplication

${value_a * value_b}

${value_a * 100}

/

Division

${value_a / value_b}

${value_a / 100}

%

Modulo (remainder)

${value_a % value_b}

${value_a % 4}

==

Test for equality

Variables : ${value_a == value_b} 

Number : ${value_a == 100}

Text : ${value_a == ‘Hello World’}

Boolean : ${value_a == true}

!=

Test for inequality

Variables : ${value_a != value_b} 

Number : ${value_a != 100}

Text : ${value_a != ‘Hello World’}

Boolean : ${value_a != true}

<

Test for less than

Variables : ${value_a < value_b} 

Number : ${value_a < 100}

>

Test for greater than

Variables : ${value_a > value_b} 

Number : ${value_a > 100}

<=

Test for less than or equal

Variables : ${value_a <= value_b} 

Number : ${value_a <= 100}

>=

Test for greater than or equal

Variables : ${value_a >= value_b} 

Number : ${value_a >= 100}

and

Test for logical AND

Variables : ${value_a and value_b} 

Boolean : ${value_a and true}

or

Test for logical OR

Variables : ${value_a or value_b} 

Boolean : ${value_a or true}

not

Boolean complement

Variables : ${not value_a} 



4 - Pre-defined variables


Below is the list of variables that are predefined and available in all workflows:


Variable
Description
Comments

pt4d_id
The unique ID of the current workflow instance. Calling the variable:
${pt4d_id}

Content example:
123

pt4d_initiator
The Google user ID of the user who started the workflow. Calling the variable:
${pt4d_initiator}

Content example:
"114793237027701729974"

pt4d_file
An object containing all the attributes of the file on which the workflow was started.
This variable is not destined to be used on its own but rather to call one of its attributes below:
  • id: the Google Drive ID of the file
  • alternateLink: the Google Drive URL of the file 

  • iconLink: the URL of the Google Drive icon of the file

  • title: the name of the document

  • tags: a table containing the list of all tags applied to the file

  • fileType: an object containing the document's File Type details

  • attributes: a table containing the list of metadata associated with this file

  • workspace: an object containing the document's workspace details


See those attributes descriptions below.

This variable exists only for workflows which scope includes files. Standalone workflows do not have a pt4d_file variable.

pt4d_file.id
The Google Drive ID of the file on which the workflow was started.
Calling the variable:
${pt4d_file.id}

Content example:
"18UZ4mZjD-JVwagLISdUtKe50vkWtLPDbmI4M0HEiHNE"

pt4d_file.alternateLink
The Google Drive URL of the file on which the workflow was started.
Calling the variable:
${pt4d_file.alternateLink}

Content example:
"https://docs.google.com/a/demo.designedforwork.com/document/d/18UZ4mZjD-JVwagLISdUtKe50vkWtLPDbmI4M0HEiHNE/edit?usp=drivesdk"

pt4d_file.iconLink
The URL of the Google Drive icon of the file on which the workflow was started.
Calling the variable:
${pt4d_file.iconLink}

Content example:
"https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.document"

pt4d_file.title
The name of the document on which the workflow was started.
Calling the variable:
${pt4d_file.title}

Content example:
"Invoice 0001"

pt4d_file.tags
A table containing the list of all tags applied to the file.
Calling the variable:
${pt4d_file.tags[0]}

Content example:
  • 0 : "Payment processed"
  • 1 : "Approved"


pt4d_file.fileType
An object containing the document's File Type details.
This variable is not destined to be used on its own but rather to call one of its attributes below:
  • id: the technical ID of the File Type
        Calling the variable:
        ${pt4d_file.fileType.id}
        Content example:
        2040001

  • name: the name of the File Type
        Calling the variable:
        ${pt4d_file.fileType.name}
        Content example:
        "Vendor Invoice"

  • description: the description of the File Type
        Calling the variable:
        ${pt4d_file.fileType.description}
        Content example:
        "Invoices received from vendors and requiring to be approved and
        processed for payment."


pt4d_file.attributes
A table containing a list of objects, themselves containing the metadata associated with this file.
The objects stored in this table have the following attributes:
  • fileTypeAttributeId: the technical ID of the File Type's metadata
  • name: the name of the metadata
  • format: the format of the metadata (free, number, list...)
  • value: the value of the metadata
  • empty: true if the metadata is empty


Note: due to the technical specificities of each format, it is recommended not to use those variables directly but rather to use the following function to reference metadata values:

${pt4d_file.getAttributeValueByName('4 - Invoice date')}


pt4d_file.workspace
An object containing the details of the workspace containing the file. This variable is not destined to be used on its own but rather to call one of its attributes below:
  • id: the Google Drive ID of the workspace root folder
        Calling the variable:
        ${pt4d_file.fworkspace.id}
        Content example:
        5918620290908160

  • name: the name of the workspace
        Calling the variable:
        ${pt4d_file.workspace.name}
        Content example:
        "[ w ] - [Demo Blue] Sandbox"



5 - Variables usage examples 


Referencing a variable or a metadata can be useful in many different cases. Below are a few examples where it can be done.


  • In a form field

Used in a label, variables and metadata can serve as a reminder of the state of the file or of the values that were entered in the previous steps. For instance, a label with the following default value : 


Invoice value: ${pt4d_file.getAttributeValueByName('6 - Invoice value')} ${pt4d_file.getAttributeValueByName('7 - Invoice currency')}


Provides the result below:



Using multiple labels referencing the appropriate metadata can thus result in a task form where all the required details are summarized:




  • To set metadata values or tags

Variables allow metadata and tags to be set to values that were entered by users in the previous task forms.




Note: to reference a variable in a “Set Metadata” task, the expert mode needs to be enabled so that the assisted input field such as list dropdowns or date fields are replaced with text fields.




  • To set conditions based on forms values


Conditional Gateways can use variables to pick a path depending on a value entered in a form.



Note: to reference a variable in a flow condition, the expert mode needs to be enabled so that the assisted input field such as list dropdowns or date fields are replaced with text fields.



  • To provide details in an email


Using variables in email notification task allow to dynamically pick the recipient and to provide a real context and clear details.


To:

${pt4d_file.getAttributeValueByName('3 - Primary contact email')}

Subject:

The invoice #${pt4d_file.getAttributeValueByName('5 - Invoice number')} has been processed and paid

Body:

<p>Dear ${pt4d_file.getAttributeValueByName('2 - Primary contact name')},</p>
<p>Please be informed that the invoice <strong>#${pt4d_file.getAttributeValueByName('5 - Invoice number')}</strong> from ${pt4d_file.getAttributeValueByName('1 - Vendor name')} has been processed and that a payment of <strong>${pt4d_file.getAttributeValueByName('6 - Invoice value')} ${pt4d_file.getAttributeValueByName('7 - Invoice currency')}</strong> has been sent accordingly.</p>
<p>You should receive it within five business days.</p>
<p>Thank you for your business.</p>