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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Receiving error: The i...
Power Automate
Answered

Receiving error: The input parameter(s) of operation 'For_each' contains invalid expression(s).

(0) ShareShare
ReportReport
Posted on by 90

Hello all

I am receiving this error message when trying to save my flow  

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

I have tried everything I know, and then some, and can't find a solution.
 

What I am trying to do is, inside a for each loop, compare each item's Coverageenddate (Coverage end date) to today's date and if the two are the same I want to change the status to expired.  

In case you are thinking there may be a null value causing the issue that is not the case as I have filtered out all null values in my get items step.

I currently have in my condition's parameters placed the following code:
 
formatDateTime(items('For_each')?['Coverageenddate'], 'yyyy-MM-dd') is equal to '{formatDateTime(today(), 'yyyy-MM-dd')}'

I have to use the today() and not utcNow() because I need to ignore the time and just compare the dates
 
 
I have even also tried this:
formatDateTime(coalesce(items('For_each')?['Coverageenddate'], '1900-01-01T00:00:00Z'), 'yyyy-MM-dd') is equal to '{formatDateTime(today(), 'yyyy-MM-dd')}'
 
and
 
formatDateTime(coalesce(items('For_each')?['Coverageenddate'], '1900-01-01T00:00:00Z'), 'yyyy-MM-dd') is equal to formatDateTime(utcNow(), 'yyyy-MM-dd') 
 
and 

formatDateTime(items('For_each')?['Coverageenddate'], 'yyyy-MM-dd') is equal to formatDateTime(utcNow(), 'yyyy-MM-dd')

the last two using the utcNow()  save without an error but then when the script runs none of the items with the matching dates are updated to expired.


below is my coding as it stands  

Would someone PLEASE help me resolve this dilema?
 
Thanks


{
  "type": "If",
  "expression": {
    "and": [
      {
        "equals": [
          "@formatDateTime(items('For_each')?['Coverageenddate'], 'yyyy-MM-dd')\r\n",
          "@{formatDateTime(today(), 'yyyy-MM-dd')}'"
        ]
      }
    ]
  },
  "actions": {
    "Send_an_email_(V2)-copy": {
      "type": "OpenApiConnection",
      "inputs": {
        "parameters": {
          "emailMessage/To": "@item()?['RequestingManager/Email']",
          "emailMessage/Subject": "Service Terminating",
          "emailMessage/Body": "<p class=\"editor-paragraph\">Hello @{outputs('requesting_Manager_profile')?['body/displayName']}<br><br>@{variables('varItemLink')}has expired.<br><br>If you need the service to continue, and have not yet done so, please submit a new request<br><br>The Operations Team</p>",
          "emailMessage/From": "M*********************************Automation@v*********m",
          "emailMessage/Bcc": "A************a@v*********m",
          "emailMessage/Importance": "Normal"
        },
        "host": {
          "apiId": "/providers/Microsoft.PowerApps/apis/shared_office365",
          "connection": "shared_office365",
          "operationId": "SendEmailV2"
        }
      },
      "runAfter": {
        "Update_item": [
          "Succeeded"
        ]
      }
    },
    "Update_item": {
      "type": "OpenApiConnection",
      "inputs": {
        "parameters": {
          "dataset": "https://v**********u.sharepoint.com/sites/M********************ing",
          "table": "a7f74738-**************-a**********2",
          "id": "@item()?['ID']",
          "item/Approval_x0020_Status/Value": "Expired"
        },
        "host": {
          "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline",
          "connection": "shared_sharepointonline",
          "operationId": "PatchItem"
        }
      }
    }
  },
  "else": {
    "actions": {}
  },
Categories:
I have the same question (0)
  • Verified answer
    Ellis Karim Profile Picture
    11,695 Super User 2025 Season 2 on at
    Hi,
     
    I would need to see the flow, but I think the expression for the condition needs to be:
     
    equals(formatDateTime(items('For_each')?['Coverageenddate'], 'yyyy-MM-dd'), utcNow('yyyy-MM-dd'))
    For easier reading:
    equals(
        formatDateTime(
            items('For_each')?['Coverageenddate'], 
            'yyyy-MM-dd'
        ), 
        utcNow('yyyy-MM-dd')
    )
    
     
    Do you have the correct name for the Apply to each loop?
     
    Ellis Karim
     
  • TJCappy Profile Picture
    90 on at
     Thanks Ellis,
     
    unfortunately this did not work ,  but I was able to get a workaround 

    I added a current time parameter and then was able to compare the coverage end date to the current time
     
    formatDateTime(item()?['Coverageenddate'], 'yyyy-MM-dd') is equal to 
    formatDateTime(body('Current_time'), 'yyyy-MM-dd')
     
     
    and this did the trick
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard