SOLVED

JSON syntax clickable button to capture/record the time and date now

%3CLINGO-SUB%20id%3D%22lingo-sub-2581811%22%20slang%3D%22en-US%22%3EJSON%20syntax%20clickable%20button%20to%20capture%2Frecord%20the%20time%20and%20date%20now%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2581811%22%20slang%3D%22en-US%22%3E%3CP%3ELooking%20for%20help%20please.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20have%20a%20list%20that%20requires%20to%20capture%20the%20time%20after%20the%20task%20is%20complete.%20is%20there%20a%20way%20using%20json%20sysntax%20to%20create%20a%20clickable%20button%20then%20the%20action%20will%20be%20to%20capture%20the%20date%20and%20time%20now%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20saw%20this%20i%20microsoft%20site%2C%20but%20instead%20of%20sending%20an%20email%20as%20an%20action%20i%20need%20to%20capture%20the%20date%20and%20time%20now.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Abbyamante_0-1627081030661.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F298113i13379479D8C93FCE%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Abbyamante_0-1627081030661.png%22%20alt%3D%22Abbyamante_0-1627081030661.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Abbyamante_1-1627081054311.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F298114i3C8104C34DF9A734%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Abbyamante_1-1627081054311.png%22%20alt%3D%22Abbyamante_1-1627081054311.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2581811%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2583460%22%20slang%3D%22en-US%22%3ERe%3A%20JSON%20syntax%20clickable%20button%20to%20capture%2Frecord%20the%20time%20and%20date%20now%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2583460%22%20slang%3D%22en-US%22%3EYou%20can%20try%20using%20a%20new%20field%20to%20capture%20the%20utcnow()%20value%2C%20I'm%20using%20that%20option%20to%20capture%20the%20time%20when%20any%20user%20changes%20some%20list..%20Did%20you%20tray%20a%20solution%20using%20flows%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2586844%22%20slang%3D%22en-US%22%3ERe%3A%20JSON%20syntax%20clickable%20button%20to%20capture%2Frecord%20the%20time%20and%20date%20now%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2586844%22%20slang%3D%22en-US%22%3ENo.%20i%20havent%20tried%20using%20or%20building%20anything%20yet.%20just%20wanted%20to%20get%20some%20ideas%20how%20to%20achieve%20this%20without%20using%20flows.%3C%2FLINGO-BODY%3E
Occasional Contributor

Looking for help please.

 

i have a list that requires to capture the time after the task is complete. is there a way using json sysntax to create a clickable button then the action will be to capture the date and time now?

 

i saw this i microsoft site, but instead of sending an email as an action i need to capture the date and time now.

 

Abbyamante_0-1627081030661.png

Abbyamante_1-1627081054311.png

 

 

6 Replies
You can try using a new field to capture the utcnow() value, I'm using that option to capture the time when any user changes some list.. Did you tray a solution using flows?
No. i havent tried using or building anything yet. just wanted to get some ideas how to achieve this without using flows.

@Abbyamante 

I've done a little digging since I'm new to "Modern SharePoint", but have been customizing older versions of SharePoint for some time now.

 

The example you provided works well since it creates a simple HTML link for each item in the list. The functionality is then based on browser and default mail client for the PC.

 

I'm not sure if you can do the same exactly since you need to update the list item. If you can find a way to update a list item via URL + query string then you could probably use the JSON approach you've provided. 

 

It does look like you can achieve what what you want with a combination of customizations. You could add a custom row action button that opens the edit form dialog. You could then create a custom "edit form" by creating a PowerApps form for it. I tried this out and added a button control that would set a "completed" date field to the current date/time. I used this PowerUsers question and answer (see RandyHayes answer) to help figure it all out. In theory you could hide all other controls except the date field with "complete now" button on this custom edit form. It's a three click solution (edit button from list item > Complete now button from custom form > Save) but it does streamline it to the effect I think you are looking for

 

I think with a bit more work you might be able to customize a form specifically for the "on save" action in PowerApps that would strictly save the current date and time to your desired field. You could then use this guy's technique to target a specific form using JSON scripting (see the last half of his guide) as you were aiming to do with this question.

 

Sorry, long winded response. I was curious myself how this might be done. It looks like a lot, but I think it can be done with the resources I linked and the PowerApps know how. All-in-all, a power automate flow might actually be easier...

this is very well explained, no apologies necessary. thank you for your response. i agree, it seems like the only way to achieve this is using the flow.

thank you again,
best response confirmed by Abbyamante (Occasional Contributor)
Solution

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


0-SPList-Versioning.png

 The trigger in Power Automate is the SharePoint when an item or a file is modified. Select your site and list.

 

1-Flow.png

 

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)

 

2-Flow.png

 

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

 

3a-Flow.png

 

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

 

3b-Flow.png

 

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()

 

4-Flow.png

 

So in this case we update the Bedar item to a status of completed:

5-SPList-StatusChanged.png

 

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: 

 

6-SPList-Completed.png

Rob
Los Gallardos
Microsoft Power Automate Community Super User 

 

thank 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!