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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Is this the correct wa...
Power Automate
Unanswered

Is this the correct way to get the first element in an array from parseJSON?

(0) ShareShare
ReportReport
Posted on by 377

Hi

I am pulling information from O365 and inserting it into a SharePoint Online list.

It works fine.

 

I now wish to check is users have "Unlicensed" in their "Licenses" property.

 

I have a parseJSON step which works for strings and will create the item in the list with all the properties.

But if I try to do this

body('Parse_JSON')?['assignedLicenses'][0]

for the licenses property then nothing seems to get created in the list.

It just runs and does nothing.

 

Thanks

P

 

pmwhelan_0-1677664344620.png

 

pmwhelan_1-1677664433643.png

 

pmwhelan_2-1677664537734.png

 

 

Categories:
  • pmwhelan Profile Picture
    377 on at

    This is what i mean by "it runs and does nothing"

     

    pmwhelan_0-1677665438665.png

     

  • Unknown geen idee Profile Picture
    1,757 on at

    Dear pmwhelan,

     

    Did you look into using the expression 'first()' to get the first array element?

    This may help you.

    More information:

    https://manueltgomes.com/reference/powerautomate-function-reference/power-automate-first-function/

     

    Please note, the syntax is a bit funny (it threw me off at the start .. but eventually you will get it).

    Happy flowing, hope it helps,

    Koen

     

     

     

  • pmwhelan Profile Picture
    377 on at

    Finally got an error

    Unable to process template language expressions in action 'Create_item' inputs at line '0' and column '0': 'The template language expression 'body('Parse_JSON')?['assignedLicenses'][0]' cannot be evaluated because property '0' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'.

  • pmwhelan Profile Picture
    377 on at

    Hi Koen

    When I try 

    first(body('Parse_JSON')?['assignedLicenses'])
    I get...

    One or more fields provided is of type 'Null', a different type is expected.

  • Unknown geen idee Profile Picture
    1,757 on at

    Dear Pmwhelan,

     

    Please view below an example of a correct syntax to grab an element out of the first entry in an array.

    Check the syntax carefully. It seems to me you have not defined it correctly.

     

    • first(outputs('Lists_items_present_in_table_-_SO_9')?['body/value'])?['ProductName']
    • first(Array)?['element']
    Happy flowing,
    Koen

     

  • Unknown geen idee Profile Picture
    1,757 on at

    I just pasted an example of a correct syntax in the reply: 

    first(outputs('Lists_items_present_in_table_-_SO_9')?['body/value'])?['ProductName']
  • pmwhelan Profile Picture
    377 on at

    Thanks.

    I'm not sure how I apply that to a JSON value though?

    This looks wrong?

    first(body('Parse_JSON')?['assignedLicenses'])?['assignedLicenses']

    but what should the second assignedLicenses be?

    thanks

  • Unknown geen idee Profile Picture
    1,757 on at

    Dear Pmwhelan,

     

    I assumed that the output from the 'Parse Json' action is an array, ... it is not an action I have used often. I have done some research and am now not so sure that the output is an array. If not, then the sugggested first() would not work.

     

    If it is however an array, I would expect the syntax to be something like:

    • first(body/value('Parse_JSON'))?['assignedLicenses']
    • first(body('Parse_JSON'))?['assignedLicenses']
  • grantjenkins Profile Picture
    11,063 Moderator on at

    Are you able to show the output from your Compose action and Parse JSON action? If you click on the Code icon on the toolbar </> and paste it in the code editor, then we can look to see exactly what you need.

  • pmwhelan Profile Picture
    377 on at

    When I go into that specific run of my flow that part is greyed out!

    Can that be fixed?

     

    pmwhelan_0-1677684304659.png

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 315 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 267

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard