web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : fgSWPQ/C7moIWzHPuYyXGy
Power Automate - Building Flows
Unanswered

Can't figure out how to extract value from message body

Like (0) ShareShare
ReportReport
Posted on 26 Aug 2021 16:12:18 by 31

Hope you good people might be able to help me figure out what I'm doing wrong, because I've been fighting with this for *hours* and I'm about ready to give up...

 

I have what I think is a trivially simple requirement: Using the AzureAD connector in a flow, I retrieve the set of groups a user is a member of using the action "Get groups of a user (V2)" the output of which is an array of group ID's. I then need to parse through that collection & determine which group(s) are dynamic membership - because you can't call the remove user from a group action against a dynamic group - if you try it throws an error...

 

I send the output of "Get groups of a user (V2)" into an apply to each loop, and call the Get Group action against each group in the collection, in order to get all of the properties of each group.

 

The property which tells me if it's dynamic or not is "grouptypes"... unfortunately it is not in the set of properties offered by the dynamic content of the get group action, but I can see that it IS in the body of the output. So I then send the body from get group to a Parse_JSON action, which IIUIC breaks out all of the name-value property pairs into individual elements which I can then reference.  This much is all good so far... Inspecting the output of the Parse_JSON action I can see the attribute is there, and it also appears in the dynamic content of the action:

PGordon1_0-1629991518342.png

PGordon1_1-1629991585350.png

This is where it starts to go sideways - I want to test the value of grouptypes in a condition... First problem  - if the Grouptypes property is empty (which it legitimately can be), the condition throws an error because it doesn't like the tested element being null.

What I see is this:

PGordon1_2-1629992496093.png

 

Which I think is telling me that it fails because the element I'm inputting (the Grouptypes item) isn't a valid array?... here's the relevant actions:

PGordon1_3-1629992624456.png

The input there is selected from the Dynamic content of the Parse_JSON action, which as can be seen above definitely IS there, IS typed as array, and DOES have the value "DynamicMembership"..

 

Ive tried pretty much every likely operator on the condition (contains, starts with, equals, etc. etc.) Every one gives me the same error that the input to the condition is invalid...

 

The odd thing is that this still happens even when the grouptypes data item DOES contain the tested value, - but looking at the raw output I wonder looking at the structure - a genuinely empty value (the group is NOT dynamic) looks like this:

PGordon1_4-1629993147389.png  

 

Looking at another group which IS dynamic, the structure is this:

PGordon1_5-1629993186038.png

Is there something hooky going on there with array elements? - in order to successfully test that value, do I need to reference into a specific array element?

 

NB: when that thought first occurred to me, I put the Parse_JSON dynamic content item Grouptypes (which is supposed to be an array remember) into another Apply to each loop, thinking that this surely would pull out each indivdual element..

 

No Matter what I do, if I try to reference that grouptypes value in any way, it throws an error....

I simplified it way down, & threw out the condition action entirely, even with nothing more than this:

PGordon1_6-1629994115177.png

The Apply to each action throws this error:

PGordon1_7-1629994160144.png

Which suggests to me that it doesn't even accept the dynamic content as input to the action?

 

 

PLEASE could someone (anyone!) suggest what's going on?? - I;m getting really quite frustrated with this now...

 

TIA

 

Paul G

 

I have the same question (0)
  • PGordon1 Profile Picture
    31 on 01 Sep 2021 at 06:24:41
    Re: Can't figure out how to extract value from message body

    I just followed instructions I found in one of the documentations pages, - to get the correct schema I ran the get-group action then in the run history showed the raw output, copied that, & pasted it into the parse_JSON action in the "Load schema from a sample" box... - you mention a good point that if of course the schema was wrong that would explain why all the dynamic content items I got from the parse_JSNO action were empty.... something worth going back & eyeballing I think...

     

    P.

     

  • Nixar Profile Picture
    28 on 01 Sep 2021 at 01:35:09
    Re: Can't figure out how to extract value from message body

    Hi,

    How did you get the schema for ParseJson action. I am also trying to use this action "Get groups of a user (V2)" to get all groups that a user belong to but could not figure out how to read the out from that action. 

    Here is the detail I posted asking for this?

    https://powerusers.microsoft.com/t5/General-Power-Automate/No-output-when-using-quot-Get-groups-of-a-user-V2-quot/m-p/1253203#M76851

  • PGordon1 Profile Picture
    31 on 27 Aug 2021 at 13:27:12
    Re: Can't figure out how to extract value from message body

    I did make some progress... After further research, it seems like the parse JSON action is fundamentally broken... the dynamic content that it generated was incorrect!

     

    All the dynamic content items generated by the action took the form:

    body('ParseJSON')?['body']?['<item>']

     

    After seeing some other reports that suggested it was being generated incorrectly, sure enough, if I ignore the dynamic content items, and enter it myself as an expression in the (correct) format:

    body('ParseJSON')?['<item>']

     

    So that's progress at least....  Next issue. I couldn't directly test against that in a condition, since it is an array object, and appears in the email I generate with it as ["DynamicMembership"]  - I can't put that in the condition as-is because I guess it then forces it to be typed as an array, and it throws an error:

    PGordon1_0-1629998477453.pngPGordon1_1-1629998490301.png

    I needed to figure out how to get it into a form that I can actually do a string comparison against... - I tried pushing it into a string variable, thus far without success - I know I can't leave the square brackets on the outside of the compare value - that gives the "it can't be an array" error.... If I take them off, the expression ALWAYS evaluates to false, I tried with and without wildcards at each end, and finally I tried just the plain string itself with no embellishments at all... - and YAY that works!

     

    At last! success! 🙂

     

    Would have been simple & straightforward were it not for the buggy JSON action...

     

    Paul G.

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 664 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 400 Moderator

#3
chiaraalina Profile Picture

chiaraalina 290

Last 30 days Overall leaderboard