cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jimbo1
Advocate I
Advocate I

Extracting Information from JSON

Hi,

I would really appreciate it if someone could assist me with the following. I have a little experience but obviously not enough. Apologies if this appears really long but I am sure it is pretty simple when you know how.

I have created the below flow:

Capture.JPG

This appears to be working correctly to produce the following JSON output:

 

{
  "template_id": "template_6c1dea62effa496b8484d91ed4d56e64",
  "audit_id": "audit_4095bd23476b49439f982144c9c39672",
  "archived": false,
  "created_at": "2018-06-01T08:08:40.768Z",
  "modified_at": "2018-06-01T08:08:40.768Z",
  "audit_data": {
    "name": "ReportName",
    "duration": 226,
    "authorship": {
      "owner": "User 1",
      "owner_id": "user_6029b16ca6954e5d858013bd9355e725",
    },
    "date_completed": "2018-06-01T08:08:35.000Z",
  },
  "template_data": {
    "authorship": {
      "owner": "Owner 1",
      "owner_id": "user_5547c753a1e04aa0a07eadc916142ffc",
    },
    "metadata": {
      "description": "Used",
    },
    "response_sets": {
      "5892b495-6f48-4455-b4f0-e221114dfb56": {
        "id": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "type": "question",
        "responses": [
          {
            "id": "e850b110-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "Yes",
          },
          {
            "id": "e85d3430-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "No",
          }
        ]
      },
      "8e8ce734-91f2-4d6a-bdcd-7de518cd3b4a": {
        "id": "8e8ce734-91f2-4d6a-bdcd-7de518cd3b4a",
        "type": "list",
        "responses": [
          {
            "id": "ad5dd665-db34-4f2c-aead-1d63ecdaa804",
            "label": "Maybe",
          },
        ]
      },
      "responseset_0b1372ca97a54475928bed87026838d4": {
        "id": "responseset_0b1372ca97a54475928bed87026838d4",
        "type": "list",
        "responses": [
          {
            "id": "f2380042-454d-4095-b2f4-d32b70ba2225",
            "label": "1",
          },
          {
            "id": "700b718e-168a-48b7-9019-9ccb587aaf20",
            "label": "2",
          },
          {
            "id": "5514b935-d691-402f-8318-2a3593029f33",
            "label": "3",
          },
          {
            "id": "7392b834-56e8-4775-a619-28003552d5c1",
            "label": "4",
          }
        ]
      },
      "responseset_a7ebe0c60fe74433bc87e55c7095cc77": {
        "id": "responseset_a7ebe0c60fe74433bc87e55c7095cc77",
        "type": "list",
        "responses": [
          {
            "id": "142db929-9c60-4e8d-a21c-3dd879a378d1",
            "label": "1",
          },
          {
            "id": "339c2722-8da0-47a0-855b-11be6102fd98",
            "label": "2",
          },
          {
            "id": "5167b720-304e-44a6-ba1f-980e1ba18479",
            "label": "3",
          },
          {
            "id": "63d0ee63-dde5-49ee-8c1c-5a6cc96ef3ff",
            "label": "4",
          }
        ]
      },
      "responseset_ac2ee987aebe4b90ba153505652dbefa": {
        "id": "responseset_ac2ee987aebe4b90ba153505652dbefa",
        "type": "list",
        "responses": [
          {
            "id": "4166ef55-5f0d-4230-920b-d86ddcea0e3a",
            "label": "1",
          },
          {
            "id": "0c19ca86-f5a2-4860-a715-1f79d00f71c2",
            "label": "2",
          },
          {
            "id": "bf814c61-15fa-4792-8235-216d511b5226",
            "label": "3",
          },
          {
            "id": "0d6e5547-1883-4591-af38-9e85a9bffd2a",
            "label": "4",
          },
          {
            "id": "1a7e1254-9a56-4b70-845a-28ffcbf175a1",
            "label": "5",
          },
          {
            "id": "36d74c30-8797-4ce7-8eb5-b4bd68b8a1d8",
            "label": "None Reccomended",
          }
        ]
      }
    }
  },
  "header_items": [
    {
      "item_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "label": "Title Page",
      "type": "section",
      "options": {
        "is_mandatory": false
      },
      "children": [
        "f3245d46-ea77-11e1-aff1-0800200c9a66",
      ]
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d46-ea77-11e1-aff1-0800200c9a66",
      "label": "D",
      "type": "textsingle",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "FW000040"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d40-ea77-11e1-aff1-0800200c9a66",
      "label": "J",
      "type": "textsingle",
      "options": {
        "weighting": 1,
      },
      "responses": {
        "text": "Jb-12345"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d41-ea77-11e1-aff1-0800200c9a66",
      "label": "Client Name:",
      "type": "textsingle",
      "options": {
        "weighting": 1,
      },
      "responses": {
        "text": "Mr Bloggs "
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d42-ea77-11e1-aff1-0800200c9a66",
      "label": "Conducted on",
      "type": "datetime",
      "options": {
        "is_mandatory": true,
      },
      "responses": {
        "datetime": "2018-06-01T08:04:47.000Z"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d43-ea77-11e1-aff1-0800200c9a66",
      "label": "Prepared by",
      "type": "textsingle",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "User 1"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d44-ea77-11e1-aff1-0800200c9a66",
      "label": "Location",
      "type": "address",
      "options": {
        "is_mandatory": false
      },
      "responses": {
        "location_text": "1 the street "
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "dc4446a3-b59a-41fc-8648-74c4042a4187",
      "label": "Site Post Code",
      "type": "textsingle",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "AA1 BB2 "
      }
    }
  ],
  "items": [
    {
      "item_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "label": "Audit",
      "type": "section",
      "scoring": {
        "combined_score": 0,
      },
      "options": {
        "is_mandatory": false
      },
      "children": [
        "1fb4adeb-75d6-49ee-a057-698ead8d0901",
        "c7331c2a-02dc-4e5d-acab-7dd167bfa6bd",
      ]
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "1fb4adeb-75d6-49ee-a057-698ead8d0901",
      "label": "Have you logged this with the office already?",
      "type": "question",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "",
        "selected": [
          {
            "id": "e85d3430-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "No",
          }
        ]
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "c7331c2a-02dc-4e5d-acab-7dd167bfa6bd",
      "label": "Job Type:",
      "type": "list",
      "scoring": {
        "score": 0,
      },
      "options": {
        "weighting": 0,
        "response_set": "responseset_0b1372ca97a54475928bed87026838d4",
        "is_mandatory": true,
      },
      "responses": {
        "selected": [
          {
            "id": "f2380042-454d-4095-b2f4-d32b70ba2225",
            "label": "1",
          }
        ]
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "46f04d8d-473b-470c-abef-82b916d56b5a",
      "label": "Please select the type of work we have attended for:",
      },
      "options": {
        "weighting": 0,
        "response_set": "responseset_a7ebe0c60fe74433bc87e55c7095cc77",
        "is_mandatory": true,
        "multiple_selection": false
      },
      "responses": {
        "selected": [
          {
            "id": "142db929-9c60-4e8d-a21c-3dd879a378d1",
            "label": "1",
          }
        ]
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "be5ffb33-323c-48a1-b033-362db99e7543",
      "label": "Work Completed:",
      "type": "text",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "Test "
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "452f177c-723d-4e5c-85b4-018ebbfca932",
      "label": "Type of Work Reccomended",
      "type": "list",
      "scoring": {
        "score": 0,
        "max_score": 0,
        "score_percentage": 0
      },
      "options": {
        "weighting": 0,
        "response_set": "responseset_ac2ee987aebe4b90ba153505652dbefa",
        "is_mandatory": true,
        "multiple_selection": true
      },
      "responses": {
        "selected": [
          {
            "id": "bf814c61-15fa-4792-8235-216d511b5226",
            "label": "Lots",
            "colour": "250,250,250",
            "score": 1,
            "short_label": "",
            "type": "unsupported_item",
            "failed": false,
            "enable_score": true
          }
        ]
      },
      "children": [
        "b006895b-e8d7-4635-b660-b71a37238b6c",
        "b220b2a3-02d2-4f60-9187-7b2e51352fb1"
      ]
    },
    {
      "parent_id": "452f177c-723d-4e5c-85b4-018ebbfca932",
      "item_id": "b006895b-e8d7-4635-b660-b71a37238b6c",
      "label": "",
      "type": "smartfield",
      "evaluation": false,
      "options": {
        "values": [
          "1a7e1254-9a56-4b70-845a-28ffcbf175a1"
        ],
        "weighting": 1,
        "condition": "35f6c132-e500-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "0e7e1034-b624-4623-a5d4-6f293ab361a3"
      ]
    },
    {
      "parent_id": "b006895b-e8d7-4635-b660-b71a37238b6c",
      "item_id": "0e7e1034-b624-4623-a5d4-6f293ab361a3",
      "label": "Have you done it?",
      "type": "question",
      "inactive": true,
      "options": {
        "weighting": 0,
        "response_set": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "is_mandatory": true
      },
      "responses": {
        "text": ""
      },
      "children": [
        "f03fdbcc-5fdc-4a86-8d14-b4df9848c82a"
      ]
    },
    {
      "parent_id": "0e7e1034-b624-4623-a5d4-6f293ab361a3",
      "item_id": "f03fdbcc-5fdc-4a86-8d14-b4df9848c82a",
      "label": "",
      "type": "smartfield",
      "inactive": true,
      "evaluation": false,
      "options": {
        "values": [
          "e850b110-d8fc-11e7-85d5-b53950ed2f0e"
        ],
        "weighting": 1,
        "condition": "3f206182-e4f6-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "7bbcbc1e-b774-4671-9a71-37a85a86c52f"
      ]
    },
    {
      "parent_id": "f03fdbcc-5fdc-4a86-8d14-b4df9848c82a",
      "item_id": "7bbcbc1e-b774-4671-9a71-37a85a86c52f",
      "label": "Please confirm you have Before, During & After Evidence",
      "type": "question",
      "inactive": true,
      "options": {
        "weighting": 0,
        "response_set": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "is_mandatory": true
      },
      "responses": {
        "text": ""
      }
    },
    {
      "parent_id": "452f177c-723d-4e5c-85b4-018ebbfca932",
      "item_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "label": "",
      "type": "smartfield",
      "evaluation": true,
      "options": {
        "weighting": 1,
        "condition": "35f6c130-e500-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "16eaef31-e71f-4835-87f7-0f74b2393c02",
        "b43fe72e-0ade-42ca-a05e-85cb15c165a4",
        "8b665afe-7c32-4864-ab41-1f73788f5786",
        "067427d9-2f06-425d-a76a-16cc2f6de301",
        "7842ed2c-08ac-47de-b956-9d930ae7a284"
      ]
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "16eaef31-e71f-4835-87f7-0f74b2393c02",
      "label": "Please add site photographs:",
      "type": "media",
      "options": {
        "weighting": 1,
        "is_mandatory": true
      },
      "responses": {},
      "media": [
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "dd7a5711-3205-4f65-beda-314501420cb3",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/dd7a5711-3205-4f65-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "31f1dc61-5c1f-40f9-957d-4e82ad3892a0",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/31f1dc61-5c1f-40f9-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "35670105-896c-4522-96d1-14421bf3d5e2",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/35670105-896c-4522-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "411e6ed3-2b0c-4df4-8430-557f4b20663e",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/411e6ed3-2b0c-4df4-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "9798ad0f-72af-4601-bd3c-8b619bd0f2b6",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/9798ad0f-72af-4601-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "e92a8599-55cc-44f4-9e61-3c2c2f93f769",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/e92a8599-55cc-44f4-..."
        }
      ]
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "b43fe72e-0ade-42ca-a05e-85cb15c165a4",
      "label": "Work Required:",
      "type": "text",
      "options": {
        "weighting": 1,
        "is_mandatory": true
      },
      "responses": {
        "text": "More Work "
      }
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "8b665afe-7c32-4864-ab41-1f73788f5786",
      "label": "Another:",
      "type": "question",
      "options": {
        "weighting": 0,
        "response_set": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "is_mandatory": true
      },
      "responses": {
        "text": "",
        "selected": [
          {
            "id": "e85d3430-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "No",
            "colour": "147,156,160",
            "score": 0,
            "short_label": "",
            "type": "text",
            "enable_score": false
          }
        ]
      },
      "children": [
        "88fb9b98-3486-41ae-a0a6-8c305f5d3219"
      ]
    },
    {
      "parent_id": "8b665afe-7c32-4864-ab41-1f73788f5786",
      "item_id": "88fb9b98-3486-41ae-a0a6-8c305f5d3219",
      "label": "",
      "type": "smartfield",
      "evaluation": false,
      "options": {
        "values": [
          "e850b110-d8fc-11e7-85d5-b53950ed2f0e"
        ],
        "weighting": 1,
        "condition": "3f206182-e4f6-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "4f829bf8-9019-474b-83f3-97cc51d75cd0"
      ]
    },
    {
      "parent_id": "88fb9b98-3486-41ae-a0a6-8c305f5d3219",
      "item_id": "4f829bf8-9019-474b-83f3-97cc51d75cd0",
      "label": "Please take a photograph of the Site Plan!",
      "type": "media",
      "inactive": true,
      "options": {
        "weighting": 1,
        "is_mandatory": true
      }
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "067427d9-2f06-425d-a76a-16cc2f6de301",
      "label": "Please indicate Urgency:",
      "type": "list",
      "options": {
        "weighting": 0,
        "response_set": "8e8ce734-91f2-4d6a-bdcd-7de518cd3b4a",
        "is_mandatory": true,
        "multiple_selection": false
      },
      "responses": {
        "selected": [
          {
            "id": "ad5dd665-db34-4f2c-aead-1d63ecdaa804",
            "label": "Urgent",
            "colour": "250,250,250",
            "score": 0,
            "short_label": "",
            "type": "text",
            "enable_score": false
          }
        ]
      }
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "7842ed2c-08ac-47de-b956-9d930ae7a284",
      "label": "Email Address (if available)",
      "type": "textsingle",
      "options": {
        "weighting": 1,
        "is_mandatory": false
      }
    }
  ]
}

 

What I am after is the information highlighted in red. I have been trying to create an array as there are multiple records for each audit. however I cannot seem to navigate my way through the JSON file to extract the correct information. Is anyone in a position to assist me with this?

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Jimbo1,

 

Do you want to extract media_id number from the JSON data that you provided?

 

I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a "Compose" action, Inputs field set to the following JSON data that you provided:
{
  "template_id": "template_6c1dea62effa496b8484d91ed4d56e64",
  "audit_id": "audit_4095bd23476b49439f982144c9c39672",
  "archived": false,
  "created_at": "2018-06-01T08:08:40.768Z",
  "modified_at": "2018-06-01T08:08:40.768Z",
  "audit_data": {
    "name": "ReportName",
    "duration": 226,
    "authorship": {
      "owner": "User 1",
      "owner_id": "user_6029b16ca6954e5d858013bd9355e725"
    },
    "date_completed": "2018-06-01T08:08:35.000Z"
  },
  "template_data": {
    "authorship": {
      "owner": "Owner 1",
      "owner_id": "user_5547c753a1e04aa0a07eadc916142ffc"
    },
    "metadata": {
      "description": "Used"
    },
    "response_sets": {
      "5892b495-6f48-4455-b4f0-e221114dfb56": {
        "id": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "type": "question",
        "responses": [
          {
            "id": "e850b110-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "Yes"
          },
          {
            "id": "e85d3430-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "No"
          }
        ]
      },
      "8e8ce734-91f2-4d6a-bdcd-7de518cd3b4a": {
        "id": "8e8ce734-91f2-4d6a-bdcd-7de518cd3b4a",
        "type": "list",
        "responses": [
          {
            "id": "ad5dd665-db34-4f2c-aead-1d63ecdaa804",
            "label": "Maybe"
          }
        ]
      },
      "responseset_0b1372ca97a54475928bed87026838d4": {
        "id": "responseset_0b1372ca97a54475928bed87026838d4",
        "type": "list",
        "responses": [
          {
            "id": "f2380042-454d-4095-b2f4-d32b70ba2225",
            "label": "1"
          },
          {
            "id": "700b718e-168a-48b7-9019-9ccb587aaf20",
            "label": "2"
          },
          {
            "id": "5514b935-d691-402f-8318-2a3593029f33",
            "label": "3"
          },
          {
            "id": "7392b834-56e8-4775-a619-28003552d5c1",
            "label": "4"
          }
        ]
      },
      "responseset_a7ebe0c60fe74433bc87e55c7095cc77": {
        "id": "responseset_a7ebe0c60fe74433bc87e55c7095cc77",
        "type": "list",
        "responses": [
          {
            "id": "142db929-9c60-4e8d-a21c-3dd879a378d1",
            "label": "1"
          },
          {
            "id": "339c2722-8da0-47a0-855b-11be6102fd98",
            "label": "2"
          },
          {
            "id": "5167b720-304e-44a6-ba1f-980e1ba18479",
            "label": "3"
          },
          {
            "id": "63d0ee63-dde5-49ee-8c1c-5a6cc96ef3ff",
            "label": "4"
          }
        ]
      },
      "responseset_ac2ee987aebe4b90ba153505652dbefa": {
        "id": "responseset_ac2ee987aebe4b90ba153505652dbefa",
        "type": "list",
        "responses": [
          {
            "id": "4166ef55-5f0d-4230-920b-d86ddcea0e3a",
            "label": "1"
          },
          {
            "id": "0c19ca86-f5a2-4860-a715-1f79d00f71c2",
            "label": "2"
          },
          {
            "id": "bf814c61-15fa-4792-8235-216d511b5226",
            "label": "3"
          },
          {
            "id": "0d6e5547-1883-4591-af38-9e85a9bffd2a",
            "label": "4"
          },
          {
            "id": "1a7e1254-9a56-4b70-845a-28ffcbf175a1",
            "label": "5"
          },
          {
            "id": "36d74c30-8797-4ce7-8eb5-b4bd68b8a1d8",
            "label": "None Reccomended"
          }
        ]
      }
    }
  },
  "header_items": [
    {
      "item_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "label": "Title Page",
      "type": "section",
      "options": {
        "is_mandatory": false
      },
      "children": [
        "f3245d46-ea77-11e1-aff1-0800200c9a66"
      ]
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d46-ea77-11e1-aff1-0800200c9a66",
      "label": "D",
      "type": "textsingle",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "FW000040"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d40-ea77-11e1-aff1-0800200c9a66",
      "label": "J",
      "type": "textsingle",
      "options": {
        "weighting": 1
      },
      "responses": {
        "text": "Jb-12345"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d41-ea77-11e1-aff1-0800200c9a66",
      "label": "Client Name:",
      "type": "textsingle",
      "options": {
        "weighting": 1
      },
      "responses": {
        "text": "Mr Bloggs "
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d42-ea77-11e1-aff1-0800200c9a66",
      "label": "Conducted on",
      "type": "datetime",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "datetime": "2018-06-01T08:04:47.000Z"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d43-ea77-11e1-aff1-0800200c9a66",
      "label": "Prepared by",
      "type": "textsingle",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "User 1"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d44-ea77-11e1-aff1-0800200c9a66",
      "label": "Location",
      "type": "address",
      "options": {
        "is_mandatory": false
      },
      "responses": {
        "location_text": "1 the street "
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "dc4446a3-b59a-41fc-8648-74c4042a4187",
      "label": "Site Post Code",
      "type": "textsingle",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "AA1 BB2 "
      }
    }
  ],
  "items": [
    {
      "item_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "label": "Audit",
      "type": "section",
      "scoring": {
        "combined_score": 0
      },
      "options": {
        "is_mandatory": false
      },
      "children": [
        "1fb4adeb-75d6-49ee-a057-698ead8d0901",
        "c7331c2a-02dc-4e5d-acab-7dd167bfa6bd"
      ]
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "1fb4adeb-75d6-49ee-a057-698ead8d0901",
      "label": "Have you logged this with the office already?",
      "type": "question",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "",
        "selected": [
          {
            "id": "e85d3430-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "No"
          }
        ]
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "c7331c2a-02dc-4e5d-acab-7dd167bfa6bd",
      "label": "Job Type:",
      "type": "list",
      "scoring": {
        "score": 0
      },
      "options": {
        "weighting": 0,
        "response_set": "responseset_0b1372ca97a54475928bed87026838d4",
        "is_mandatory": true
      },
      "responses": {
        "selected": [
          {
            "id": "f2380042-454d-4095-b2f4-d32b70ba2225",
            "label": "1"
          }
        ]
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "46f04d8d-473b-470c-abef-82b916d56b5a",
      "label": "Please select the type of work we have attended for:",
      "options": {
        "weighting": 0,
        "response_set": "responseset_a7ebe0c60fe74433bc87e55c7095cc77",
        "is_mandatory": true,
        "multiple_selection": false
      },
      "responses": {
        "selected": [
          {
            "id": "142db929-9c60-4e8d-a21c-3dd879a378d1",
            "label": "1"
          }
        ]
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "be5ffb33-323c-48a1-b033-362db99e7543",
      "label": "Work Completed:",
      "type": "text",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "Test "
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "452f177c-723d-4e5c-85b4-018ebbfca932",
      "label": "Type of Work Reccomended",
      "type": "list",
      "scoring": {
        "score": 0,
        "max_score": 0,
        "score_percentage": 0
      },
      "options": {
        "weighting": 0,
        "response_set": "responseset_ac2ee987aebe4b90ba153505652dbefa",
        "is_mandatory": true,
        "multiple_selection": true
      },
      "responses": {
        "selected": [
          {
            "id": "bf814c61-15fa-4792-8235-216d511b5226",
            "label": "Lots",
            "colour": "250,250,250",
            "score": 1,
            "short_label": "",
            "type": "unsupported_item",
            "failed": false,
            "enable_score": true
          }
        ]
      },
      "children": [
        "b006895b-e8d7-4635-b660-b71a37238b6c",
        "b220b2a3-02d2-4f60-9187-7b2e51352fb1"
      ]
    },
    {
      "parent_id": "452f177c-723d-4e5c-85b4-018ebbfca932",
      "item_id": "b006895b-e8d7-4635-b660-b71a37238b6c",
      "label": "",
      "type": "smartfield",
      "evaluation": false,
      "options": {
        "values": [
          "1a7e1254-9a56-4b70-845a-28ffcbf175a1"
        ],
        "weighting": 1,
        "condition": "35f6c132-e500-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "0e7e1034-b624-4623-a5d4-6f293ab361a3"
      ]
    },
    {
      "parent_id": "b006895b-e8d7-4635-b660-b71a37238b6c",
      "item_id": "0e7e1034-b624-4623-a5d4-6f293ab361a3",
      "label": "Have you done it?",
      "type": "question",
      "inactive": true,
      "options": {
        "weighting": 0,
        "response_set": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "is_mandatory": true
      },
      "responses": {
        "text": ""
      },
      "children": [
        "f03fdbcc-5fdc-4a86-8d14-b4df9848c82a"
      ]
    },
    {
      "parent_id": "0e7e1034-b624-4623-a5d4-6f293ab361a3",
      "item_id": "f03fdbcc-5fdc-4a86-8d14-b4df9848c82a",
      "label": "",
      "type": "smartfield",
      "inactive": true,
      "evaluation": false,
      "options": {
        "values": [
          "e850b110-d8fc-11e7-85d5-b53950ed2f0e"
        ],
        "weighting": 1,
        "condition": "3f206182-e4f6-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "7bbcbc1e-b774-4671-9a71-37a85a86c52f"
      ]
    },
    {
      "parent_id": "f03fdbcc-5fdc-4a86-8d14-b4df9848c82a",
      "item_id": "7bbcbc1e-b774-4671-9a71-37a85a86c52f",
      "label": "Please confirm you have Before, During & After Evidence",
      "type": "question",
      "inactive": true,
      "options": {
        "weighting": 0,
        "response_set": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "is_mandatory": true
      },
      "responses": {
        "text": ""
      }
    },
    {
      "parent_id": "452f177c-723d-4e5c-85b4-018ebbfca932",
      "item_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "label": "",
      "type": "smartfield",
      "evaluation": true,
      "options": {
        "weighting": 1,
        "condition": "35f6c130-e500-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "16eaef31-e71f-4835-87f7-0f74b2393c02",
        "b43fe72e-0ade-42ca-a05e-85cb15c165a4",
        "8b665afe-7c32-4864-ab41-1f73788f5786",
        "067427d9-2f06-425d-a76a-16cc2f6de301",
        "7842ed2c-08ac-47de-b956-9d930ae7a284"
      ]
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "16eaef31-e71f-4835-87f7-0f74b2393c02",
      "label": "Please add site photographs:",
      "type": "media",
      "options": {
        "weighting": 1,
        "is_mandatory": true
      },
      "responses": {},
      "media": [
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "dd7a5711-3205-4f65-beda-314501420cb3",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/dd7a5711-3205-4f65-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "31f1dc61-5c1f-40f9-957d-4e82ad3892a0",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/31f1dc61-5c1f-40f9-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "35670105-896c-4522-96d1-14421bf3d5e2",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/35670105-896c-4522-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "411e6ed3-2b0c-4df4-8430-557f4b20663e",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/411e6ed3-2b0c-4df4-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "9798ad0f-72af-4601-bd3c-8b619bd0f2b6",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/9798ad0f-72af-4601-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "e92a8599-55cc-44f4-9e61-3c2c2f93f769",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/e92a8599-55cc-44f4-..."
        }
      ]
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "b43fe72e-0ade-42ca-a05e-85cb15c165a4",
      "label": "Work Required:",
      "type": "text",
      "options": {
        "weighting": 1,
        "is_mandatory": true
      },
      "responses": {
        "text": "More Work "
      }
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "8b665afe-7c32-4864-ab41-1f73788f5786",
      "label": "Another:",
      "type": "question",
      "options": {
        "weighting": 0,
        "response_set": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "is_mandatory": true
      },
      "responses": {
        "text": "",
        "selected": [
          {
            "id": "e85d3430-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "No",
            "colour": "147,156,160",
            "score": 0,
            "short_label": "",
            "type": "text",
            "enable_score": false
          }
        ]
      },
      "children": [
        "88fb9b98-3486-41ae-a0a6-8c305f5d3219"
      ]
    },
    {
      "parent_id": "8b665afe-7c32-4864-ab41-1f73788f5786",
      "item_id": "88fb9b98-3486-41ae-a0a6-8c305f5d3219",
      "label": "",
      "type": "smartfield",
      "evaluation": false,
      "options": {
        "values": [
          "e850b110-d8fc-11e7-85d5-b53950ed2f0e"
        ],
        "weighting": 1,
        "condition": "3f206182-e4f6-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "4f829bf8-9019-474b-83f3-97cc51d75cd0"
      ]
    },
    {
      "parent_id": "88fb9b98-3486-41ae-a0a6-8c305f5d3219",
      "item_id": "4f829bf8-9019-474b-83f3-97cc51d75cd0",
      "label": "Please take a photograph of the Site Plan!",
      "type": "media",
      "inactive": true,
      "options": {
        "weighting": 1,
        "is_mandatory": true
      }
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "067427d9-2f06-425d-a76a-16cc2f6de301",
      "label": "Please indicate Urgency:",
      "type": "list",
      "options": {
        "weighting": 0,
        "response_set": "8e8ce734-91f2-4d6a-bdcd-7de518cd3b4a",
        "is_mandatory": true,
        "multiple_selection": false
      },
      "responses": {
        "selected": [
          {
            "id": "ad5dd665-db34-4f2c-aead-1d63ecdaa804",
            "label": "Urgent",
            "colour": "250,250,250",
            "score": 0,
            "short_label": "",
            "type": "text",
            "enable_score": false
          }
        ]
      }
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "7842ed2c-08ac-47de-b956-9d930ae7a284",
      "label": "Email Address (if available)",
      "type": "textsingle",
      "options": {
        "weighting": 1,
        "is_mandatory": false
      }
    }
  ]
}

 

  • Add a Variables-> "Initialize variable" action, Name set to MediaIDArray, type set to Array and Value set to empty.
  • Add a "Filter array" action, From set to following formula:
outputs('Compose')?['items']

Click "Edit in advanced mode", type the following formula:

@equals(item()?['item_id'], '16eaef31-e71f-4835-87f7-0f74b2393c02')
  • Add a "Apply to each" action, input parameter set to following formula:
first(body('Filter_array'))?['media']

Within "Apply to each" action, add a "Compose 2" action, Inputs field set to following formula:

item()?['media_id']

Add a "Append to array" action, Name set to MediaIDArray, Value set to output of the "Compose 2" action.

 

  • Under "Apply to each" action, add a "Compose 3" action, Inputs field set to MediaIDArray variable.

Image reference:2.JPG

 

3.JPG

The flow works successfully as below:4.JPG

 

 

More details about using expression in flow actions, please check the following article:

Use expression in flow actions

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thanks for your help Kris, That worked perfectly.

 

 

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @Jimbo1,

 

Do you want to extract media_id number from the JSON data that you provided?

 

I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a "Compose" action, Inputs field set to the following JSON data that you provided:
{
  "template_id": "template_6c1dea62effa496b8484d91ed4d56e64",
  "audit_id": "audit_4095bd23476b49439f982144c9c39672",
  "archived": false,
  "created_at": "2018-06-01T08:08:40.768Z",
  "modified_at": "2018-06-01T08:08:40.768Z",
  "audit_data": {
    "name": "ReportName",
    "duration": 226,
    "authorship": {
      "owner": "User 1",
      "owner_id": "user_6029b16ca6954e5d858013bd9355e725"
    },
    "date_completed": "2018-06-01T08:08:35.000Z"
  },
  "template_data": {
    "authorship": {
      "owner": "Owner 1",
      "owner_id": "user_5547c753a1e04aa0a07eadc916142ffc"
    },
    "metadata": {
      "description": "Used"
    },
    "response_sets": {
      "5892b495-6f48-4455-b4f0-e221114dfb56": {
        "id": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "type": "question",
        "responses": [
          {
            "id": "e850b110-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "Yes"
          },
          {
            "id": "e85d3430-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "No"
          }
        ]
      },
      "8e8ce734-91f2-4d6a-bdcd-7de518cd3b4a": {
        "id": "8e8ce734-91f2-4d6a-bdcd-7de518cd3b4a",
        "type": "list",
        "responses": [
          {
            "id": "ad5dd665-db34-4f2c-aead-1d63ecdaa804",
            "label": "Maybe"
          }
        ]
      },
      "responseset_0b1372ca97a54475928bed87026838d4": {
        "id": "responseset_0b1372ca97a54475928bed87026838d4",
        "type": "list",
        "responses": [
          {
            "id": "f2380042-454d-4095-b2f4-d32b70ba2225",
            "label": "1"
          },
          {
            "id": "700b718e-168a-48b7-9019-9ccb587aaf20",
            "label": "2"
          },
          {
            "id": "5514b935-d691-402f-8318-2a3593029f33",
            "label": "3"
          },
          {
            "id": "7392b834-56e8-4775-a619-28003552d5c1",
            "label": "4"
          }
        ]
      },
      "responseset_a7ebe0c60fe74433bc87e55c7095cc77": {
        "id": "responseset_a7ebe0c60fe74433bc87e55c7095cc77",
        "type": "list",
        "responses": [
          {
            "id": "142db929-9c60-4e8d-a21c-3dd879a378d1",
            "label": "1"
          },
          {
            "id": "339c2722-8da0-47a0-855b-11be6102fd98",
            "label": "2"
          },
          {
            "id": "5167b720-304e-44a6-ba1f-980e1ba18479",
            "label": "3"
          },
          {
            "id": "63d0ee63-dde5-49ee-8c1c-5a6cc96ef3ff",
            "label": "4"
          }
        ]
      },
      "responseset_ac2ee987aebe4b90ba153505652dbefa": {
        "id": "responseset_ac2ee987aebe4b90ba153505652dbefa",
        "type": "list",
        "responses": [
          {
            "id": "4166ef55-5f0d-4230-920b-d86ddcea0e3a",
            "label": "1"
          },
          {
            "id": "0c19ca86-f5a2-4860-a715-1f79d00f71c2",
            "label": "2"
          },
          {
            "id": "bf814c61-15fa-4792-8235-216d511b5226",
            "label": "3"
          },
          {
            "id": "0d6e5547-1883-4591-af38-9e85a9bffd2a",
            "label": "4"
          },
          {
            "id": "1a7e1254-9a56-4b70-845a-28ffcbf175a1",
            "label": "5"
          },
          {
            "id": "36d74c30-8797-4ce7-8eb5-b4bd68b8a1d8",
            "label": "None Reccomended"
          }
        ]
      }
    }
  },
  "header_items": [
    {
      "item_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "label": "Title Page",
      "type": "section",
      "options": {
        "is_mandatory": false
      },
      "children": [
        "f3245d46-ea77-11e1-aff1-0800200c9a66"
      ]
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d46-ea77-11e1-aff1-0800200c9a66",
      "label": "D",
      "type": "textsingle",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "FW000040"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d40-ea77-11e1-aff1-0800200c9a66",
      "label": "J",
      "type": "textsingle",
      "options": {
        "weighting": 1
      },
      "responses": {
        "text": "Jb-12345"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d41-ea77-11e1-aff1-0800200c9a66",
      "label": "Client Name:",
      "type": "textsingle",
      "options": {
        "weighting": 1
      },
      "responses": {
        "text": "Mr Bloggs "
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d42-ea77-11e1-aff1-0800200c9a66",
      "label": "Conducted on",
      "type": "datetime",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "datetime": "2018-06-01T08:04:47.000Z"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d43-ea77-11e1-aff1-0800200c9a66",
      "label": "Prepared by",
      "type": "textsingle",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "User 1"
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "f3245d44-ea77-11e1-aff1-0800200c9a66",
      "label": "Location",
      "type": "address",
      "options": {
        "is_mandatory": false
      },
      "responses": {
        "location_text": "1 the street "
      }
    },
    {
      "parent_id": "f3245d39-ea77-11e1-aff1-0800200c9a66",
      "item_id": "dc4446a3-b59a-41fc-8648-74c4042a4187",
      "label": "Site Post Code",
      "type": "textsingle",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "AA1 BB2 "
      }
    }
  ],
  "items": [
    {
      "item_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "label": "Audit",
      "type": "section",
      "scoring": {
        "combined_score": 0
      },
      "options": {
        "is_mandatory": false
      },
      "children": [
        "1fb4adeb-75d6-49ee-a057-698ead8d0901",
        "c7331c2a-02dc-4e5d-acab-7dd167bfa6bd"
      ]
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "1fb4adeb-75d6-49ee-a057-698ead8d0901",
      "label": "Have you logged this with the office already?",
      "type": "question",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "",
        "selected": [
          {
            "id": "e85d3430-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "No"
          }
        ]
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "c7331c2a-02dc-4e5d-acab-7dd167bfa6bd",
      "label": "Job Type:",
      "type": "list",
      "scoring": {
        "score": 0
      },
      "options": {
        "weighting": 0,
        "response_set": "responseset_0b1372ca97a54475928bed87026838d4",
        "is_mandatory": true
      },
      "responses": {
        "selected": [
          {
            "id": "f2380042-454d-4095-b2f4-d32b70ba2225",
            "label": "1"
          }
        ]
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "46f04d8d-473b-470c-abef-82b916d56b5a",
      "label": "Please select the type of work we have attended for:",
      "options": {
        "weighting": 0,
        "response_set": "responseset_a7ebe0c60fe74433bc87e55c7095cc77",
        "is_mandatory": true,
        "multiple_selection": false
      },
      "responses": {
        "selected": [
          {
            "id": "142db929-9c60-4e8d-a21c-3dd879a378d1",
            "label": "1"
          }
        ]
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "be5ffb33-323c-48a1-b033-362db99e7543",
      "label": "Work Completed:",
      "type": "text",
      "options": {
        "is_mandatory": true
      },
      "responses": {
        "text": "Test "
      }
    },
    {
      "parent_id": "46b43d15-284f-4dd9-9a45-ec575a58574b",
      "item_id": "452f177c-723d-4e5c-85b4-018ebbfca932",
      "label": "Type of Work Reccomended",
      "type": "list",
      "scoring": {
        "score": 0,
        "max_score": 0,
        "score_percentage": 0
      },
      "options": {
        "weighting": 0,
        "response_set": "responseset_ac2ee987aebe4b90ba153505652dbefa",
        "is_mandatory": true,
        "multiple_selection": true
      },
      "responses": {
        "selected": [
          {
            "id": "bf814c61-15fa-4792-8235-216d511b5226",
            "label": "Lots",
            "colour": "250,250,250",
            "score": 1,
            "short_label": "",
            "type": "unsupported_item",
            "failed": false,
            "enable_score": true
          }
        ]
      },
      "children": [
        "b006895b-e8d7-4635-b660-b71a37238b6c",
        "b220b2a3-02d2-4f60-9187-7b2e51352fb1"
      ]
    },
    {
      "parent_id": "452f177c-723d-4e5c-85b4-018ebbfca932",
      "item_id": "b006895b-e8d7-4635-b660-b71a37238b6c",
      "label": "",
      "type": "smartfield",
      "evaluation": false,
      "options": {
        "values": [
          "1a7e1254-9a56-4b70-845a-28ffcbf175a1"
        ],
        "weighting": 1,
        "condition": "35f6c132-e500-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "0e7e1034-b624-4623-a5d4-6f293ab361a3"
      ]
    },
    {
      "parent_id": "b006895b-e8d7-4635-b660-b71a37238b6c",
      "item_id": "0e7e1034-b624-4623-a5d4-6f293ab361a3",
      "label": "Have you done it?",
      "type": "question",
      "inactive": true,
      "options": {
        "weighting": 0,
        "response_set": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "is_mandatory": true
      },
      "responses": {
        "text": ""
      },
      "children": [
        "f03fdbcc-5fdc-4a86-8d14-b4df9848c82a"
      ]
    },
    {
      "parent_id": "0e7e1034-b624-4623-a5d4-6f293ab361a3",
      "item_id": "f03fdbcc-5fdc-4a86-8d14-b4df9848c82a",
      "label": "",
      "type": "smartfield",
      "inactive": true,
      "evaluation": false,
      "options": {
        "values": [
          "e850b110-d8fc-11e7-85d5-b53950ed2f0e"
        ],
        "weighting": 1,
        "condition": "3f206182-e4f6-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "7bbcbc1e-b774-4671-9a71-37a85a86c52f"
      ]
    },
    {
      "parent_id": "f03fdbcc-5fdc-4a86-8d14-b4df9848c82a",
      "item_id": "7bbcbc1e-b774-4671-9a71-37a85a86c52f",
      "label": "Please confirm you have Before, During & After Evidence",
      "type": "question",
      "inactive": true,
      "options": {
        "weighting": 0,
        "response_set": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "is_mandatory": true
      },
      "responses": {
        "text": ""
      }
    },
    {
      "parent_id": "452f177c-723d-4e5c-85b4-018ebbfca932",
      "item_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "label": "",
      "type": "smartfield",
      "evaluation": true,
      "options": {
        "weighting": 1,
        "condition": "35f6c130-e500-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "16eaef31-e71f-4835-87f7-0f74b2393c02",
        "b43fe72e-0ade-42ca-a05e-85cb15c165a4",
        "8b665afe-7c32-4864-ab41-1f73788f5786",
        "067427d9-2f06-425d-a76a-16cc2f6de301",
        "7842ed2c-08ac-47de-b956-9d930ae7a284"
      ]
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "16eaef31-e71f-4835-87f7-0f74b2393c02",
      "label": "Please add site photographs:",
      "type": "media",
      "options": {
        "weighting": 1,
        "is_mandatory": true
      },
      "responses": {},
      "media": [
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "dd7a5711-3205-4f65-beda-314501420cb3",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/dd7a5711-3205-4f65-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "31f1dc61-5c1f-40f9-957d-4e82ad3892a0",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/31f1dc61-5c1f-40f9-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "35670105-896c-4522-96d1-14421bf3d5e2",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/35670105-896c-4522-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "411e6ed3-2b0c-4df4-8430-557f4b20663e",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/411e6ed3-2b0c-4df4-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "9798ad0f-72af-4601-bd3c-8b619bd0f2b6",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/9798ad0f-72af-4601-..."
        },
        {
          "date_created": "2018-06-01T08:06:20.000Z",
          "file_ext": "jpg",
          "label": "6c1dea62-effa-496b-8484-d91ed4d56e64",
          "media_id": "e92a8599-55cc-44f4-9e61-3c2c2f93f769",
          "href": "https://api.safetyculture.io/audits/audit_4095bd23476b49439f982144c9c39672/media/e92a8599-55cc-44f4-..."
        }
      ]
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "b43fe72e-0ade-42ca-a05e-85cb15c165a4",
      "label": "Work Required:",
      "type": "text",
      "options": {
        "weighting": 1,
        "is_mandatory": true
      },
      "responses": {
        "text": "More Work "
      }
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "8b665afe-7c32-4864-ab41-1f73788f5786",
      "label": "Another:",
      "type": "question",
      "options": {
        "weighting": 0,
        "response_set": "5892b495-6f48-4455-b4f0-e221114dfb56",
        "is_mandatory": true
      },
      "responses": {
        "text": "",
        "selected": [
          {
            "id": "e85d3430-d8fc-11e7-85d5-b53950ed2f0e",
            "label": "No",
            "colour": "147,156,160",
            "score": 0,
            "short_label": "",
            "type": "text",
            "enable_score": false
          }
        ]
      },
      "children": [
        "88fb9b98-3486-41ae-a0a6-8c305f5d3219"
      ]
    },
    {
      "parent_id": "8b665afe-7c32-4864-ab41-1f73788f5786",
      "item_id": "88fb9b98-3486-41ae-a0a6-8c305f5d3219",
      "label": "",
      "type": "smartfield",
      "evaluation": false,
      "options": {
        "values": [
          "e850b110-d8fc-11e7-85d5-b53950ed2f0e"
        ],
        "weighting": 1,
        "condition": "3f206182-e4f6-11e1-aff1-0800200c9a66",
        "is_mandatory": false
      },
      "children": [
        "4f829bf8-9019-474b-83f3-97cc51d75cd0"
      ]
    },
    {
      "parent_id": "88fb9b98-3486-41ae-a0a6-8c305f5d3219",
      "item_id": "4f829bf8-9019-474b-83f3-97cc51d75cd0",
      "label": "Please take a photograph of the Site Plan!",
      "type": "media",
      "inactive": true,
      "options": {
        "weighting": 1,
        "is_mandatory": true
      }
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "067427d9-2f06-425d-a76a-16cc2f6de301",
      "label": "Please indicate Urgency:",
      "type": "list",
      "options": {
        "weighting": 0,
        "response_set": "8e8ce734-91f2-4d6a-bdcd-7de518cd3b4a",
        "is_mandatory": true,
        "multiple_selection": false
      },
      "responses": {
        "selected": [
          {
            "id": "ad5dd665-db34-4f2c-aead-1d63ecdaa804",
            "label": "Urgent",
            "colour": "250,250,250",
            "score": 0,
            "short_label": "",
            "type": "text",
            "enable_score": false
          }
        ]
      }
    },
    {
      "parent_id": "b220b2a3-02d2-4f60-9187-7b2e51352fb1",
      "item_id": "7842ed2c-08ac-47de-b956-9d930ae7a284",
      "label": "Email Address (if available)",
      "type": "textsingle",
      "options": {
        "weighting": 1,
        "is_mandatory": false
      }
    }
  ]
}

 

  • Add a Variables-> "Initialize variable" action, Name set to MediaIDArray, type set to Array and Value set to empty.
  • Add a "Filter array" action, From set to following formula:
outputs('Compose')?['items']

Click "Edit in advanced mode", type the following formula:

@equals(item()?['item_id'], '16eaef31-e71f-4835-87f7-0f74b2393c02')
  • Add a "Apply to each" action, input parameter set to following formula:
first(body('Filter_array'))?['media']

Within "Apply to each" action, add a "Compose 2" action, Inputs field set to following formula:

item()?['media_id']

Add a "Append to array" action, Name set to MediaIDArray, Value set to output of the "Compose 2" action.

 

  • Under "Apply to each" action, add a "Compose 3" action, Inputs field set to MediaIDArray variable.

Image reference:2.JPG

 

3.JPG

The flow works successfully as below:4.JPG

 

 

More details about using expression in flow actions, please check the following article:

Use expression in flow actions

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thanks for your help Kris, That worked perfectly.

 

 

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (843)