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

Help with syntax problem - trying to dynamically access an array element using a variable

I'm trying to use a variable of type integer to access a specific element in an array variable but the action always errors out.  

Components 

variable intIndex of type integer

variable arrayRoles of type array

Both of these variable are approriately initialized and have the correct values

 

Compose Action using the following function always errors

variables('arrayRoles')['intIndex']
also tried
variables('arrayRoles')[int('intIndex')]
with the same results
Flow Error.PNG

 

I feel there must be some basic syntax problem that I'm not getting.  Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Help with syntax problem - trying to dynamically access an array element using a variable

Hi @AndreSchlender ,

 

Please try this Expression:

variables('arrayRoles')[variables('intIndex')]

Image reference:

24.PNG

Hope it helps.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Help with syntax problem - trying to dynamically access an array element using a variable

If you could provide an expanded screenshot of your Flow and steps, and of any detailed error messages you're receiving we could likely better assist you.

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

AndreSchlender
Level: Powered On

Re: Help with syntax problem - trying to dynamically access an array element using a variable

Fair enough and thanks for responding.  Seem to struggle to upload an image into this message, so please have a look a the screenshot through the OneDrive link below.  This is just a test flow with three actions.  The function in compose action that throws the error is listed in original post.  Thanks again.

 

Flow Error screenshot

Community Support Team
Community Support Team

Re: Help with syntax problem - trying to dynamically access an array element using a variable

Hi @AndreSchlender ,

 

Please try this Expression:

variables('arrayRoles')[variables('intIndex')]

Image reference:

24.PNG

Hope it helps.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

AndreSchlender
Level: Powered On

Re: Help with syntax problem - trying to dynamically access an array element using a variable

Hi Barry,

great that worked.  I knew it had to be something simple that stared me in the face. 

Much appreciated.

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

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 Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,209)