Last updated:

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.

What are expressions in Power Automate?

Within Power Automate, expressions serve as a suite of fundamental functions designed to retrieve and manipulate data. Simply put, they enable you to craft formulas tailored to your data requirements. These expressions facilitate a variety of operations, such as converting dates into Coordinated Universal Time (UTC) and amalgamating fields to create specific text strings.

When integrating with SafetyCulture, expressions are used to export and extract inspection data, such as question responses and other metadata. If you want to take a look at how the expressions work in action, check out our guides on creating flows that automatically export inspection data to SharePoint lists and Excel Online.

If you'd like to learn more about expressions in Power Automate, Microsoft offers a training module that takes you through the fundamentals.

How do expressions work when integrating with SafetyCulture?

When it comes to exporting inspection data using Power Automate expressions, the "Filter array" and "Compose" actions are used in combination to export inspection questions' responses.

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: &

  • Backslash: \

  • Forward slash: /

  • Question mark: ?

Please note that exporting data from the following types of inspection questions is not supported:

  • Questions with repeat sections.

  • Multiple-choice questions that have "multiple selection" enabled.

Filter array

The "Data Operations" connector's "Filter" action is used to specify the question, of which response data you want to export. As you may be creating several filter arrays to specify different question responses you want to export, we recommend renaming each filter array you create to something you can refer back to easily, such as the question label.

Each filter array action you configure should look something like the following example, with either the question's item ID or label in the "Filter Query" field on the right-hand side:

An example of the filter array action in a Power Automate flow.

From

In the "From" field, click image and enter one of the following expressions, based on where the question is in the inspection:

  • Title page:

    body('Get_a_specific_inspection')['header_items']

  • All other inspection pages:

    body('Get_a_specific_inspection')['items']

Filter Query

In the "Filter Query" fields, click image and enter one of the following expressions, based on how you want 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 specifed in the corresponding "Filter array" action.

In the sample expressions below, 'Filter_array' in the expressions 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.

Each compose action you configure should look something like the following example, with a single expression to extract data based on the relevant question's response type:

An example of the compose action in a Power Automate flow.

Inputs

In the "Inputs" field, click image and enter one of the following expressions, 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.

In the "Inputs" field, click image and enter one of the following expressions:

  • 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 for each site or level's name remains the same even if your organization's site labels are customized.

Need more help?
In this article