Sharepoint List Date Field with current date icon

James Trogdon 46 Reputation points
2022-04-17T23:20:16.36+00:00

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!

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,604 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,663 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Xuyan Ding - MSFT 7,561 Reputation points
    2022-04-19T05:54:07.083+00:00

    Hi @James Trogdon

    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. James Trogdon 46 Reputation points
    2022-04-21T11:58:42.117+00:00

    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!


  3. Xuyan Ding - MSFT 7,561 Reputation points
    2022-04-27T10:01:07.737+00:00

    Hi @James Trogdon ,

    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.

    0 comments No comments