cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Arankin1
Frequent Visitor

Dynamic Content Disappears when Expression Being Typed

I am trying to write an expression to modify a dynamic value.  The dynamic value appears on the list, but disappears when I try to add to to an expression.  There is only an option to select the body or value from the get items action.

1 ACCEPTED SOLUTION

Accepted Solutions

If you look at the formula I typed in, the get items is inside a First() function.  That selects the first record in the array and then gets the field from it.  In your case you don't have anything to select a specific record.  You are trying to format the array itself as a dateTime.  You can't use that in a comparison, because its an array not a value.  The equivalent of using first() in your case would be something like the following.

formatDateTime(outputs('Get_items')?['body/value'][0]?['ABS_x0020_Start_x002d_Finish'], 'yyyy-mm-dd')

 Note the inclusion of [0] to get the specific array element to convert.  Or you could use first() like I do in my example above.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

3 REPLIES 3
Pstork1
Dual Super User
Dual Super User

This is a common problem because usually the expression works at a different level than the value you want.  For example if you want to get a value from the First record in an array.  ONce you type First() only the Body and value are available.  Because that is what goes inside the First.  The field name then gets appended on after the closing parentheses on the function.  So that has to be done manually.  Here's an example using First()

first(outputs('Get_items')?['body/value'])?['FieldName']

everything inside the first() function is available from the dynamic content dialog.  but ?['Fieldname'] has to be typed manually.  



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Arankin1
Frequent Visitor

Thanks.  Maybe I'm not understanding this correctly.  

 

When I type in the following:

 

formatDateTime(outputs('Get_items')?['body/value']?['ABS_x0020_Start_x002d_Finish'], 'yyyy-mm-dd')

 

I get this error when I run the flow:

 

The execution of template action 'Filter_array' failed: The evaluation of 'query' action 'where' expression '@greaterOrEquals(formatDateTime(outputs('Get_items')?['body/value']?['ABS_x0020_Start_x002d_Finish'], 'yyyy-mm-dd'), getPastTime(7, 'Day', 'yyyy-mm-dd'))' failed: 'The template language expression 'greaterOrEquals(formatDateTime(outputs('Get_items')?['body/value']?['ABS_x0020_Start_x002d_Finish'], 'yyyy-mm-dd'), getPastTime(7, 'Day', 'yyyy-mm-dd'))' cannot be evaluated because property 'ABS_x0020_Start_x002d_Finish' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.

 

When I try this formula:

 

formatDateTime(outputs('Get_items')?['body/value']?, 'yyyy-mm-dd')['ABS_x0020_Start_x002d_Finish']

 

I get an error in the expression box.

If you look at the formula I typed in, the get items is inside a First() function.  That selects the first record in the array and then gets the field from it.  In your case you don't have anything to select a specific record.  You are trying to format the array itself as a dateTime.  You can't use that in a comparison, because its an array not a value.  The equivalent of using first() in your case would be something like the following.

formatDateTime(outputs('Get_items')?['body/value'][0]?['ABS_x0020_Start_x002d_Finish'], 'yyyy-mm-dd')

 Note the inclusion of [0] to get the specific array element to convert.  Or you could use first() like I do in my example above.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (1,319)