JSON Sharepoint List Action Button - update to today's date

Brass Contributor

I have a SharePoint list with a column button. When the button is pressed, based on other conditions, I want to update a SharePoint column (internal name SuspendEndDate) to the current date. SuspendEndDate is a date/Time column formatted as DateOnly, Standard format.

My format action on the button looks like this. What am I missing on the setValue for SuspendEndDate? Currently the column is not updating at all!

 

{
"elmType": "button",
"txtContent": "=if([$Status]=='Rejected','Resubmit',if([$Status]=='Suspend','Reinstate',''))",
"customRowAction": {
"action": "setValue",
"actionInput": {
"Status": "=if([$Status]=='Rejected','Resubmit',if([$Status]=='Suspend','Reinstate',''))",
"SuspendEndDate": "=if([$Status]=='Suspend',@now,'')"
}
},
"style": {
"border": "none",
"background-color": "=if([$Status]=='Rejected','#A4262C',if([$Status]=='Suspend','#a68cf6',''))",
"color": "#ffffff",
"cursor": "pointer",
"visibility": "=if([$Status]=='Rejected','visible',if([$Status]=='Suspend','visible','hidden'))"
}
}
2 Replies

Hi @Annette1101 - try using utcNow() first.

 

Otherwise, check out this post on dates, SharePoint and JSON: SharePoint Online Date calculation with JSON - Microsoft Community Hub.

 

My first instinct as I'm more familiar with Power Automate than JSON was to have the button kick off a flow, like this post explains JSON syntax clickable button to capture/record the time and date now - Microsoft Community Hub

 

Hope that helps!

Unfortunately, utcNow() doesn't work! I am not inclined to kick off a Power Automate from the button as it would require the user to perform a few clicks. I do have a Power Automate that runs on a trigger when the status changes, based on a trigger, so I will add that field update to that flow instead of trying to change it with a setValue as it clearly doesn't work for a date field.