The data formatter task, as a Jinja code editor, provide a dedicated space for data extraction, manipulation, organization, and testing. They typically serve as holders of preparatory data for subsequent workflows, and are commonly referenced by command, conditional, or other data formatter tasks.
Examples
Example 1 - Date-Time Parsing and Splitting
Build and test the following playbook using the Get Current UTC Time command, ensuring that all tasks auto-run.
Click on the icon of the command task.
Navigate to the Return Data tab, then note the date time format.
Insert the following Jinja code into the data formatter task editor.
CODE
Date: {{ PlaybookData | jsonpath('$.["Get Current Date and Time"].returnData') | split(' ') | first }}
Time: {{
PlaybookData | jsonpath('$.["Get Current Date and Time"].returnData') | split(' ') | last
}}
Configure Workflow Separator with the following conditional logic:
CODE
{% set data = PlaybookData | jsonpath('$.["Unwind Task"].contextData.data') %}
{% if data | contains_key('demoKeyA1') or data | contains_key('demoKeyA2') %}
Workflow A
{% elif data | contains_key('demoKeyB1') or data | contains_key('demoKeyB2') %}
Workflow B
{% elif data | contains_key('demoKeyC1') or data | contains_key('demoKeyC2') %}
Workflow C
{% else %}
Next
{% endif %}