Forum Discussion
Populate a date column automatically
- Jan 04, 2022
Sharepoint_Chris this is not difficult and it compares the current version of the item with the previous one, so you MUST make sure that in your list settings -> versioning settings that Item Version History is set to on. I normally set the number of versions to 10.
In this example I prepared for a similar forum post a while back we are checking whether the Status column has changed and, if so, whether the status is now Completed. If it is then add today's date in the Completed column.
The trigger in the flow is "when an item or a file is modified":
The first action is "get changes for an item or a file (properties only)". For the ID field select ID from the when an item or a file is modified section of the dynamic content box.
For the Since field you need to add the following expression to get the previous version:
sub(int(triggerOutputs()?['body/{VersionNumber}']),1)Next, add a condition:
- in the left box select Has Column Changed: Status
- in the middle box select is equal to
- in the right box type true
Add a new row to the condition and if your SharePoint status column is a choice column then select Status value, if it's not a choice column then just select Status, and again select is equal to and then type Completed in the right hand box:
Finally, you can leave the red if no channel empty, but in the green if yes channel add an Update item action and in the Completed field add an expresion of utcNow()
So the Status has changed to completed and the flow runs and adds today's date into the Completed field.:
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Sharepoint_Chris Why have you got an apply to each after the trigger? The get changes action must follow immediately after the trigger as in my earlier screenshots, there shouldn't be an apply to each there.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Once I complete the site address, list name, and ID field it sub-groups the triggers and adds the "Apply to Each" trigger.
This is what shows initially and it changes as soon as I complete the ID field.