Expression for triggerBody parsing

MS Techie 2,751 Reputation points
2023-03-30T19:00:04.5933333+00:00

My Logic App trigger Body has the following content. I want to select value of @odata.id field under resourceData section.

What will be the Expression Query ?

{
  "value": [
    {
      "changeType": "updated",
      "clientState": "SecretClientValue",
      "resource": "Groups/f8abdf73-9b12-4eed-9d37-7xxxx498bbc",
      "resourceData": {
        "@odata.type": "#Microsoft.Graph.Group",
        "@odata.id": "Groups/xxxxx-9b12-4eed-9d37-78c843kkbbbc",
        "id": "f8abdf73-9b12-4eed-9d37-78c843498bbc",
        "organizationId": "3245xxxx2435243",
        "sequenceNumber": 638123xxxx992401565600,
        "members@delta": [
          {
            "id": "990cf7dd-da21-439b-bd31-9fd83bd82f81"
          }
        ]
      },
      "subscriptionExpirationDateTime": "2023-04-31T18:23:45.9356913-07:00",
      "subscriptionId": "b4xxxx456-1795-40ea-b8ed-6d44a528d010",
      "tenantId": "xxxxx"
    }
  ]
}
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,551 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sonny Gillissen 3,751 Reputation points Volunteer Moderator
    2023-03-31T04:54:38.5266667+00:00

    Hi MS Techie

    Thanks for reaching out on Microsoft Q&A!

    Your triggerBody contains an array (value), so the answer is not a one-off as it depends on whether this array could potentially contain more records.

    When assuming you only need the first record of the array, you can use this code to get the correct value:

    first(triggerBody()['value'])['resourceData']['@odata.id']

    If you want every value, you could use a ‘For each’ or ‘Select’ action to loop over every record to retrieve the values (depending on your requirements, or you could set the ‘splitOn’ value in your Logic App:

    https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-actions-triggers#trigger-multiple-runs-on-an-array

    Please click ‘Accept answer’ if you find my response helpful. Feel free to drop additional queries in the comments below!

    Kind regards,

    Sonny

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.