cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jeffha77
Level: Powered On

Target array item in compose

I'm trying to concatenate a string with email address from a multi choice people picker. As compose does not allow the use of the people picker data im doing an update item and then pulling the data from that update item. I'm having issues with the compose, as the people picker was multi choice it made the update item a loop so the data is in an array. When i run the compose it doesnt work becuase it can access the array.

 

CONCAT('https://company-my.sharepoint.com/User%20Photos/Profile%20Pictures/',REPLACE(body('Update_item')?['imageurl'],'@company.com',''),'_company_com_LThumb.jpg')

 

I need to figure out how to target the first item in this array -> body('Update_item')?['imageurl']

3 REPLIES 3
Community Support Team
Community Support Team

Re: Target array item in compose

Hi @jeffha77,

 

Could you please share a screenshot of your flow's configuration?

Could you please show a bit  more about your SharePoint list?

Further, could you please share a bit more about the array that you mentioned?

 

If you want to target the first item of an array, I think the first() function could could achieve your needs. 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 Variables-> "Initialize variable" action, Name set to OriginalArray, Type set to Array and Value set to the following formula:
[
  {
    "Name": "Kris",
    "Age": 24
  },
  {
    "Name": "Angelina",
    "Age": 27
  },
  {
    "Name": "Ancherl",
    "Age": 29
  }
]

Note: I use the "Initialize variable" action to create an array in my flow.

 

  • Add a "Compose" action, Inputs set to the following formula:
first(variables('OriginalArray'))

Image reference:2.JPG

The flow works successfully as below:3.JPG

 

On your side, if you want to target the first item in this array -> body('Update_item')?['imageurl'], please take a try with the following formula within "Compose" action:

first(body('Update_item')?['imageurl'])

4.JPG

 

 

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.
jeffha77
Level: Powered On

Re: Target array item in compose

This is the whole flow,

Capture1.JPG

 

This is where im having the issue, under if no,

Capture2.JPG

 

 using "first()" does not work, i still get the same error

 

Unable to process template language expressions in action 'Compose_2' inputs at line '1' and column '2153': 'The template language expression 'CONCAT('https://company-my.sharepoint.com/User%20Photos/Profile%20Pictures/',REPLACE(First(body('Update_item...')' cannot be evaluated because property 'imageurl' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.

Highlighted
aronhenning
Level: Power Up

Re: Target array item in compose

You need to move ?['imageurl'] outside the bracket
from the inside to the outside:
body('Update_item') - the body of your item
first() - select first row of that body
?['imageurl'] - select index imageurl from the selected line
 
the full string now reads as follows:
first(body('Update_item'))?['imageurl']

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (6,039)