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.

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

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.

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

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.

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

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

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,009)