Looks like Copilot led you wrong. AI is not great at this stuff, so I wouldn't recommend letting it write your code for you. Use it to validate complex formatting if needed, or use it to search for resources, but not for direct code suggestions.
I just went and built this flow so here's how I made it work:
Let's start with the SharePoint List created for this. My list has two fields that I added and am using:
I added the fields FileID and LastModified. I'm not using the built in ID and Modified fields because those track the list item itself, not the file properties we want to compare to. Note we can't use the properties of the file itself either, because Modified will always be within the last hour because that modification is what triggers our flow.
Next up is the Get Items action:
Note that the "Order By" value is not an expression, it's just plain text. The filter query is:
FileID eq '@{triggerOutputs()?['body/{Identifier}']}' and LastModified gt datetime'@{formatdatetime(addhours(utcnow(),-1),'yyyy-MM-ddTHH:mm:ssZ')}'
Note that the above code is formatted to copy/paste directly into the text field.
This filter query is an ODATA formatted filter, checking two things:
- If the trigger's file identifier is listed in our SP List
- If our custom LastModified field is within the last hour (greater than the current time minus one hour and formatted the way we want)
After that we move to our Condition:
That expression is:
length(outputs('Get_items')?['body/value'])
Note that this is formatted to be copy/pasted into the Expression Editor
This is checking to see if we got anything back from our Get Items action.
Now we move into the results of our Condition:
If yes, we update the existing List row to set the LastModified time to the current time, formatted the way we want:
formatdatetime(utcnow(),'yyyy-MM-ddTHH:mm:ssZ')
The ID expression is:
outputs('Get_items')?['body/value']?[0]?['ID']
This expression will skip the need for a loop by directly referencing the first ID value
On the If No side, first we send the email and then we create the list item so future runs will know that this file was recently modified. We're using the trigger's Identifier value and setting our LastModified time to now in the format we want:
formatdatetime(utcnow(),'yyyy-MM-ddTHH:mm:ssZ')
Note that if you browse into the list the timestamps may not show in your expected timezone, but we're storing it as UTC and comparing UTC against it so the math will math.