question

JamesTrogdon-5501 avatar image
0 Votes"
JamesTrogdon-5501 asked XuyanDingMSFT-4872 answered

Sharepoint List Date Field with current date icon

I have a SharePoint list that I would like to add a icon beside my date fields that when clicked would place the current date and time in that field. I've looked at a workflow but to trigger that it would require the item to be modified and it can take up to 5 minutes for the data to refresh. I'm looking at using json formating to possibly do this since I believe it would be a quicker update. Here's my fields:

193669-image.png



I was hoping somebody might have accomplished the same thing and could guide me to some json code that could help me. Thanks for any info you can give me!

office-sharepoint-onlinesharepoint-dev
image.png (4.6 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for your question. We are currently looking into this issue and will give you an update as soon as possible. Thank you for your understanding and support.

0 Votes 0 ·
XuyanDingMSFT-4872 avatar image
0 Votes"
XuyanDingMSFT-4872 answered JamesTrogdon-5501 commented

Hi @JamesTrogdon-5501

I suggest that you refresh the data by creating a flow. I tried it and it takes about a minute or so. Specific steps are as follows.

1.Create a column of type Yes/No, the default value is No.
When you choose Yes, a refresh will be triggered. After a refresh, the flow automatically changes the value to the default.
194099-screenshot-2022-04-18-175228.png

2.Create a flow to perform the refresh.
Integrate->Power Automate->See your flows->New flow->Automated cloud flow->Select 'When an item is created or modified'->Create
194100-screenshot-2022-04-18-175424.png
193950-screenshot-2022-04-18-175722.png
194105-screenshot-2022-04-18-175840.png

3.Fill in the Site Address and List Name->+New step->Select Condition.
194121-screenshot-2022-04-18-180341.png
194060-screenshot-2022-04-18-180529.png

4.Fill in the selection criteria: column(update) is equal to true.
Where true is to be selected from the expression.
Add an action to 'if yes'->Choose 'Update item'->Fill in the corresponding information->Select the expression utcNow() for the column of date and time, and select No for the column value that determines whether to execute a flow->Save
194048-screenshot-2022-04-18-180735.png
194049-screenshot-2022-04-18-181457.png
194070-screenshot-2022-04-18-181748.png

5.Select the update column as Yes in the list to execute a flow.
Edit->Select Yes->Save
194019-screenshot-2022-04-18-182619.png

6.Once the flow runs successfully, the list is refreshed to the current time and date, and the update column is changed from the check before the run to unchecked.
The next time you need to refresh, select the update column as Yes again.
194029-image.png
194020-image.png



If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for the screenshots but I should have been more clear. When a driver picks up a truck, I would need him to click a button that would fill in the Picked Up Date and Time column. When the same driver delivers the truck at the customer site, they would click a button to set the Delivery time. Once those dates and times are set they will not be changed unless somebody presses the button again.

I have tried a workflow like you mentioned but with an Automated flow and the license of Power Automate we have (Office 365), it can take up to 5 minutes for the data to refresh. I was hoping to use the column formatting and the "setvalue" option to immediately set the column value. The only other way I know of is to create a Power Automate app which I believe I could control the flow update time from there. I think creating an app for this is overkill since I believe it can be accomplished in the list.

I'm looking for code to put in the column formatting advanced option that could "set the value" of the another column.

0 Votes 0 ·

Hi @JamesTrogdon-5501,

Per my test, it is not able to refresh the date field by setting the column format via code. I still recommend that you use flow to perform datetime refresh.

0 Votes 0 ·
JamesTrogdon-5501 avatar image
0 Votes"
JamesTrogdon-5501 answered XuyanDingMSFT-4872 commented

I was able to figure out what was not working. I'm new to SharePoint and found out you can't use the "setValue" json code on a HIDDEN column. The column has to be visible. Here's the code I used to create a single button that timestamps the columns I need:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"customRowAction": {
"action": "setValue",
"actionInput": {
"PickedUp": "@now"
}
},
"attributes": {
"class": "ms-fontColor-themeblack ms-fontColor-themePrimary--hover"
},
"style": {
"border": "none",
"background-color": "transparent",
"cursor": "pointer"
},
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "Upload"
},
"style": {
"padding-right": "15px",
"font-size": "24px"
}
},
{
"elmType": "span",
"txtContent": "=if(@currentField <= Date('01/01/1900'),'',@currentField)",
"style": {
"font-size": "14px"
}
}
]
}

All the user has to do is click the icon and the timestamp immediately appears. Much quicker than using a flow. Thanks for the help!

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Congratulations on solving this issue and thanks for sharing your solution.

0 Votes 0 ·
XuyanDingMSFT-4872 avatar image
0 Votes"
XuyanDingMSFT-4872 answered

Hi @JamesTrogdon-5501,

I'm glad to hear you solve the problem ,if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.
By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others.". and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:

[Sharepoint List Date Field with current date icon]
Issue Symptom:
I have a SharePoint list that I would like to add a icon beside my date fields that when clicked would place the current date and time in that field. I've looked at a workflow but to trigger that it would require the item to be modified and it can take up to 5 minutes for the data to refresh. I'm looking at using json formating to possibly do this since I believe it would be a quicker update.

Current status:
Eventually, creating a single button is implemented in code.

You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.