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

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

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
Highlighted
Super User II
Super User II

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!

Highlighted
Helper I
Helper I

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

Highlighted
Community Support
Community Support

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

Highlighted
Helper I
Helper I

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

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (6,819)