Forum Discussion
JSON syntax clickable button to capture/record the time and date now
- Jul 26, 2021
Abbyamante you could trigger a flow with a JSON-formatted button but you don't need to, it can all be done automatically with a fairly simple flow in Power Automate.
First in your list settings -> versioning settings you MUST turn on item version history. This is because we comparing the current version with the previus one.
In this example we have status column which is a choice type and a Completed column which is datetime and includes the time. We will be checking to see if the Status column has changed AND the status is now Complete. If this is the case it will update the Completed column with the current date and time.
The trigger in Power Automate is the SharePoint when an item or a file is modified. Select your site and list.
Then the first action in the flow is to get changes for an item or a file (properties only). In the ID field select ID from the dynamic content box on the right. In the since field you need an expression so over in the dynamic content box click the Expression tab and copy&paste the following expression in then click the OK button (mine shows as Update as I have previously added the expression):
sub(int(triggerOutputs()?['body/{VersionNumber}']),1)Next, add a condition and in the left field select Has Column Changed: Status from the dynamic content then select is equal to then in the right field type true
Then add a new row and select Status Value for the left field (it's Status Value and not just Status as the column is a choice column), then select is equal to and in the right field type Completed
The conditin gives you a red if no channel which you can leave empty and a green if yes channel where you add an Update item action. You'll need to select your site and list again, select ID from the dynamic content box and any other columns which are mandatory which in my case is title. Then in the Completed field add an expression of utcNow()
So in this case we update the Bedar item to a status of completed:
The flow runs and updates it with the current date and time. It can take a 10 or 20 seconds sometimes for the flow to complete and add the date/time in:
Rob
Los Gallardos
Microsoft Power Automate Community Super User
thank you again,
Abbyamante you could trigger a flow with a JSON-formatted button but you don't need to, it can all be done automatically with a fairly simple flow in Power Automate.
First in your list settings -> versioning settings you MUST turn on item version history. This is because we comparing the current version with the previus one.
In this example we have status column which is a choice type and a Completed column which is datetime and includes the time. We will be checking to see if the Status column has changed AND the status is now Complete. If this is the case it will update the Completed column with the current date and time.
The trigger in Power Automate is the SharePoint when an item or a file is modified. Select your site and list.
Then the first action in the flow is to get changes for an item or a file (properties only). In the ID field select ID from the dynamic content box on the right. In the since field you need an expression so over in the dynamic content box click the Expression tab and copy&paste the following expression in then click the OK button (mine shows as Update as I have previously added the expression):
Next, add a condition and in the left field select Has Column Changed: Status from the dynamic content then select is equal to then in the right field type true
Then add a new row and select Status Value for the left field (it's Status Value and not just Status as the column is a choice column), then select is equal to and in the right field type Completed
The conditin gives you a red if no channel which you can leave empty and a green if yes channel where you add an Update item action. You'll need to select your site and list again, select ID from the dynamic content box and any other columns which are mandatory which in my case is title. Then in the Completed field add an expression of utcNow()
So in this case we update the Bedar item to a status of completed:
The flow runs and updates it with the current date and time. It can take a 10 or 20 seconds sometimes for the flow to complete and add the date/time in:
Rob
Los Gallardos
Microsoft Power Automate Community Super User
- AbbyamanteAug 18, 2021Brass Contributorthank you so much for this idea! its very well explained and all the pictures helps a lot to easily follow step by step how it gets done!
thank you so much!