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 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_ChrisJan 04, 2022Copper ContributorThank you, Rob. With some tweaking and minor adjustments, I could get everything to work.
Thanks for the help!- JTJ98Apr 21, 2022Copper Contributor
I have created a flow using the examples provided in this post to enter the date into a column called Completion Date when a user marks the sharepoint item (Status column) completed, and send an email to my user to complete a survey.
My list is configured for versioning (15) but the flow does not execute as it does not recognize the Status Column being changed to Completed. I have tried both equals to and contains for the Status condition but nothing is working. I used Terminate in the No condition for testing purposes. Any ideas what is missing? Thanks.
- RobElliottApr 21, 2022Silver Contributor
Rob
Los Gallardos
Microsoft Power Automate Community Super User
- Sharepoint_ChrisJan 04, 2022Copper Contributor
Hello Rob,
Thanks for the quick response. I am still unable to get it to work, not sure what I am doing wrong. I have followed all your instructions, but when I select "get changes from an Item or a file (properties only) it gets sub -sorted under an action that says "Apply to Each." I am not sure if that impacts this automation. Also, after selecting the condition - I enter all the necessary fields. Many required fields require information within our list, so I select the corresponding "dynamic content" that matches that field. I have included screenshots below.- RobElliottJan 04, 2022Silver Contributor
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- Sharepoint_ChrisJan 04, 2022Copper Contributor
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.