- Integrations
- Power Automate
- Power Automate: Expressions with SafetyCulture inspection data
Power Automate: Expressions with SafetyCulture inspection data
Take a look at some of the Power Automate expressions that you can use to export SafetyCulture inspection data.
Power Automate (previously Microsoft Flow) offers a rich set of actions that you can use to automate your workflows with SafetyCulture (formerly iAuditor), such as uploading inspection reports. However, you can take your integrations game to the next level by exporting data within inspections, specifically question responses, using Power Automate's Workflow Definition Language, called expressions.
If you want to take a look at how the expressions work in action, check out our guides on creating flows automatically export inspection data to SharePoint lists and Excel Online.
Take note
When it comes to exporting inspection data on Power Automate, the "Filter array" and "Compose" actions are used in combination to export inspection questions' responses.
Inspection data that is within the following types of questions cannot be exported:
Questions with repeat sections.
Multiple-choice questions that have "multiple selection" enabled.
All expressions contain references to the names of actions you create in a flow, such as the expression "body('Get_a_specific_inspection')['items']" referencing the "Get a specific inspection" action. To ensure that your expressions can be easily created without issue, please avoid using the following symbols in your action names should you rename them:
Left angle bracket: <
Right angle bracket: >
Percent: %
Ampersand or and: &
Backslash: \
Forward slash: /
Question mark: ?
Filter array
The "Data Operations" connector's "Filter" action is used to specify the question, of which its response data you wish to export.
As you may be creating several filter arrays to specify different questions' responses you wish to export, we recommend that you click on the upper-right of the action and "Rename" it to something you can refer back to as the question label, such as "Jobsite Hazard Check".
Array to filter
Click the "Array to filter" field, then copy and paste the following expressions accordingly, based on where the question is in the inspection:
body('Get_a_specific_inspection')['header_items']
All other inspection pages:
body('Get_a_specific_inspection')['items']
Choose a value
Click the "Choose a value" field, then copy and paste the following expressions accordingly, based on how you wish to filter for the question:
Filter by the unique identifier (recommended) with the question item ID as the corresponding value:
item()['item_id']
Filter by the label with the question label or name as the corresponding value:
item()['label']
Compose
The "Data Operations" connector's "Compose" action is used to extract the response from the question item you specify in the "Filter array" action.
Please note that the 'Filter_array'
in the samples below refers to the default name of the filter array action. If you followed our recommendation and renamed the action, you should match the expression with the new name. For example, if the filter array action was renamed to "Jobsite Hazard Check", the expression should replace 'Filter_array'
with 'Jobsite_Hazard_Check'
, using underscores (_) to substitute spaces.
Inputs
Click the "Inputs" field, then copy and paste the following expressions accordingly, based on the question's response type:
Multiple-choice (excluding multiple selection enabled questions):
body('Filter_array')?[0]?['responses']?['selected']?[0]?['label']
Text answer (including Person, Document number, and Number responses):
body('Filter_array')?[0]?['responses']?['text']
Date & Time (including Inspection date response):
body('Filter_array')?[0]?['responses']?['datetime']
Location (including Inspection location):
body('Filter_array')?[0]?['responses']?['location_text']
Checkbox and Slider:
body('Filter_array')?[0]?['responses']?['value']
Signature (name):
body('Filter_array')?[0]?['responses']?['name']
Inputs - Sites
If your organization uses the Sites feature, the site of an inspection, as well as the levels the site is nested under, can also be exported. As an exception, you don't need to have a corresponding filter array action to extract site or level names.
Click the "Inputs" field, then copy and paste the following expressions accordingly:
Site name
body('Get_a_specific_inspection')?['audit_data']?['site']?['name']
Area name
body('Get_a_specific_inspection')?['audit_data']?['site']?['area']?['name']
Region name
body('Get_a_specific_inspection')?['audit_data']?['site']?['region']?['name']
State name
body('Get_a_specific_inspection')?['audit_data']?['site']?['state']?['name']
Country name
body('Get_a_specific_inspection')?['audit_data']?['site']?['country']?['name']
The expression to get each site or level's name remains the same even if your organization's site labels are customized.
Was this page helpful?
Thank you for letting us know.