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
Pstork1
Dual Super User III
Dual Super User III

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 III
Dual Super User III

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.

Pstork1
Dual Super User III
Dual Super User III

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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (3,300)