cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

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
Highlighted
Community Support
Community Support

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.
Highlighted

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

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (8,112)