Any Idea how to setValue to a datetime Field?
Hi, i´ve tried to set a datetime value to a datetime field with the setValue actiion. But in eveery case i tried it only sets the date with 00:00 as time string.
Any idea how to sollve it? here is my code:
{
"elmType": "div",
"children": [
{
"elmType": "button",
"customRowAction": {
"action": "setValue",
"actionInput": {
"gesperrt": "False",
"Changes_Counter": 0,
"Changed_Members": "0",
"Changed_Functions": "0",
"Changed_GeneralData": "0",
"Changed_Admins": "0",
"Changed_Owners": "0",
"Change": "=toDateString(@now)"
}
},
"style": {
"border": "none",
"pointer-events": "=if( (([$gesperrt] == True), 'auto', 'none')"
},
"children": [
...
]
}
]
}
Change is my DatetIme Field i want to update
Hi, @dborchers-gc !!
Try removing the toDateString and changing it to the following.
"Change": "@now"
Hi, @dborchers-gc !!
Try removing the toDateString and changing it to the following.
"Change": "@now"
no sorry, it doesnt work. Only @now seems to also set only the date
Can you give a look in this repo sample, maybe can help you https://github.com/pnp/List-Formatting/tree/73f8fb4b71e21403a9084a2ec085cb122ab93b55/column-samples/date-update-format
Hey Guys, maybe i found the reason why its not working for me but i have no idea how to solve it.
The problem seems to be taht the setValue function with the "@now" value would st a dateime with seconds in it. But the standard datetime fields need a datetime value with only hh:mm
Ive Test that in a simple text field, you see here. Any idea?

here is the code:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"style": {
"flex-directon": "row",
"justify-content": "left",
"align-items": "center",
"flex-wrap": "nowrap"
},
"children": [
{
"elmType": "div",
"style": {
"display": "inherit",
"flex-directon": "row",
"justify-content": "left",
"align-items": "center",
"flex-wrap": "wrap"
},
"children": [
{
"elmType": "button",
"customRowAction": {
"action": "setValue",
"actionInput": {
"TextDate": "=@now"
}
},
"attributes": {
"class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
},
"style": {
"border": "none",
"background-color": "transparent",
"cursor": "pointer",
"display": "flex",
"flex-directon": "row",
"justify-content": "left",
"align-items": "center",
"flex-wrap": "wrap"
},
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "CircleAdditionSolid"
},
"style": {
"padding": "4px"
}
},
{
"elmType": "span",
"txtContent": "CHANGE",
"style": {
"word-break": "keep-all"
}
}
]
}
]
}
]
}
Hi @dborchers-gc,
Did you try with the date format of your site?`
"actionInput": {
"TextDate": "= getMonth(@now)+'/'+getDate(@now)+'/'+getYear(@now) +' 00:00 AM'"
}
@aaclage that works but i need the time too.
At the end i just want to compare my own datetime with the modified datetime and if the difference is to high something would happen - thts my whole usecase
But i want to have a way where i can set the owndate by setValue action in JSON, by powershell and by powerautomate action
@dborchers-gc
You also need the seconds?
Yes i guess it would be better
But Maybe you have another idea. Here is my whole usecase:
A Power Automate Flow cannot start directly after changing a list item but i would like to lock editing the list item after changing some values in it. I tried to do that with a custoimdatetime-field and i comparte the modified field with this custoimdatetime-field
My Flows will change this custoimdatetime-field too but the user cannot change it. So i think i will have a way to see differneces between changes from the uiser and changes from my flows