web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / 'For_each' contains an...
Power Automate
Unanswered

'For_each' contains an invalid expression - but I got the expression from Dynamic Content

(1) ShareShare
ReportReport
Posted on by 7

I am really at my wits end here.

My flow was working, but I had to adjust some date values so that an empty field would stop inputting today's date.

Now when I try to save the flow, I get an error message saying "The input parameter(s) of operation 'For_each' contains invalid expression(s). Fix invalid expression(s) for the input parameter(s) of operation 'For_each'."

Problem is, I got the expression from Dynamic Content, and nothing in the 'For_each' flow was changed.

Flow check shows no errors as well:

jorgy556_0-1706218193308.png

Any ideas?

Categories:
I have the same question (0)
  • wskinnermctc Profile Picture
    6,519 Moderator on at

    Delete all of the steps, including the trigger, and recreate the flow. It will remove the need for a For Each.

     

    Don't make a new flow, just delete the trigger and re-add it.

     

    You can't initialize a variable inside of an apply to each. I don't know how it let you do that in the first place.

     

    How about this since you already made the variables.

    • Delete Create Item
    • Clear the initialize variable fields, so that they aren't referencing anything.
    • Move the initialize variable actions outside of the For Each.
    • Delete get response details
    • Delete the trigger
    • Re-add the trigger
    • Re-add get response details
    • Now refill the variable fields
    • Re-add Create Item
  • jorgy556 Profile Picture
    7 on at

    Ah, yeah, that seemed to do it.

    However, I'm now running into this error:


    "OpenApiOperationParameterTypeConversionFailed
    The 'inputs.parameters' of workflow operation 'Create_item' of type 'OpenApiConnection' is not valid. Error details: Input parameter 'item/PurchaseDate' is required to be of type 'String/date'. The runtime value '""' to be converted doesn't have the expected format 'String/date'."

     

    I have the Dynamic parameter set to: "

    item/PurchaseDate": "@{body('Get_response_details')?['r798aa527047d4848a55f37d494327b23']}",

    Do I need a function in there too?
  • wskinnermctc Profile Picture
    6,519 Moderator on at

    That is happening because you are using a form response that is a text string and it is "" empty/blank. You can't put a blank "" into a date field.

     

    So you need to use an expression to check the value and see if it is empty/blank, and if so use null, else use the form response.

     

    I don't know exactly the expression to use since I don't want to make a form and test it. But it will be something like one of these below.

     

    If the form response is empty, then put null, else use the form response:

    if(empty(trim(body('Get_response_details')?['r798aa527047d4848a55f37d494327b23'])),null,body('Get_response_details')?['r798aa527047d4848a55f37d494327b23'])

     

    If the form response equals null, then put null, else use the form response:

    if(equals(trim(body('Get_response_details')?['r798aa527047d4848a55f37d494327b23']),null),null,body('Get_response_details')?['r798aa527047d4848a55f37d494327b23'])

     

    If the form response is equal to '' blank, then put null, else use the form response:

    if(equals(trim(body('Get_response_details')?['r798aa527047d4848a55f37d494327b23']),''),null,body('Get_response_details')?['r798aa527047d4848a55f37d494327b23'])

     

    If the length (number of characters) of the form response is equal to 0 zero, then put null, else use the form response:

    if(equals(length(trim(body('Get_response_details')?['r798aa527047d4848a55f37d494327b23'])),int(0)),null,body('Get_response_details')?['r798aa527047d4848a55f37d494327b23'])

     

    The last one should work for sure, but it has the most extra functions. The trim() function in all of the expressions is to remove any leading or trailing spaces, sometimes that helps clear a blank value.

     

    Try these until one of them works. If none of them work, you could also try using '' instead of null and see if that helps. So it would be if the form response is empty then '' , else form response. 

    If the form response is empty, then put '', else use the form response:

    if(empty(trim(body('Get_response_details')?['r798aa527047d4848a55f37d494327b23'])),'',body('Get_response_details')?['r798aa527047d4848a55f37d494327b23'])
    

     

    See if one of those works for you.

  • jorgy556 Profile Picture
    7 on at

    Hmm, alright, I seemed to have worked that detail out; but now it's just putting 01/25/2024 into the column for every entry; instead of blank if the response is left blank. None of the above expressions worked, I kept getting the same error; so I'm not sure if I'm doing something wrong with my PurchaseDate variable?

    jorgy556_0-1706305413931.png

    jorgy556_1-1706305446168.png

    jorgy556_2-1706305595836.pngjorgy556_3-1706305603938.png


    Also, do you know how to get the Submission Time other date/time fields to go into local time zone at all?

     



Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 820

#3
Haque Profile Picture

Haque 505

Last 30 days Overall leaderboard