Set the current time using a SharePoint Designer 2010 workflow
Learn how you can use an Update List Item workflow action in SharePoint Designer and the workflow context to set a field in a SharePoint list to the value of the current time.
You have a SharePoint list that contains a text field named CurrentTime in which you want to save the current time (without the date) by using a SharePoint Designer 2010 workflow.
You can retrieve the current date and time from the workflow context and then use this to return the time as a short time.
To use a SharePoint Designer workflow to set the current time:
- Create a new SharePoint Designer 2010 List Workflow and associate it with the SharePoint list that contains the CurrentTime field.
- Select Action > List Actions > Update List Item to add an Update List Item workflow action to Step 1.
- Click this list in the Update List Item workflow action.
- On the Update List Item dialog box, leave Current Item selected in the List drop-down list box, and then click Add.
- On the Value Assignment dialog box, select CurrentTime from the Set this field drop-down list box, and then click the formula button behind the To this value text box.
- On the Lookup for Single line of text dialog box, select Workflow Context from the Data source drop-down list box, select Date and Time Started from the Field from source drop-down list box, select Short Time from the Return field as drop-down list box, and click OK.
- Click OK when closing all open dialog boxes.
- Publish the SharePoint Designer workflow to SharePoint and test it.
The final SharePoint Designer 2010 workflow should resemble the following figure:
Figure 1. SharePoint Designer workflow action used to set the current time.
And the chain of dialog boxes used to construct the inner workings of the SharePoint Designer workflow action should resemble the following figure:
Figure 2. Setting the current time through SharePoint Designer workflow dialog boxes.
Now as soon as the workflow has run the CurrentTime field should contain a time such as for example 10:39 PM.
- How to create a List Workflow in SharePoint Designer 2010
- Construct a date from strings in a SharePoint Designer 2010 workflow
- Define workflow variables in SharePoint Designer 2010