5

How do I capture date and time when status of task is changed?

I have 3 different columns Date Assigned, Date In Progress, Date Completed.

When a task is assigned to a user, is there a way Date assigned column gets the date & time automatically? If yes, how do we do?

Similarly when user changes task to In Progress state, Date In Progress should get date & time & similarly when task is closed by user, Date Completed column should get the time-stamp, so that I can calculate time taken for each task and status in between.

I am using SharePoint 2010.

1

Old question, but I thought I'd put what we do, since we do this a lot. We add a CEWP to the EditForm.js page with the requisite script references

var todayFormat = new Date().format('MM/dd/yyyy');
$("select[title='Task Status']").change(function() {
    switch($(this).val()) {
        case 'In Progress': {
            $('input[title="Date In Progress"]').val(todayFormat);
            break;
            }
        case 'Needs Edits': {

                break;
        }

    }

});

For when a task is assigned, I do that through a Designer workflow. I add a LastAssignedTo field to the list, and mark it as a hidden field. Then, in workflow I can test to see if the assigned to field has changed.

if currentitem:assignedTo is not equal to currentitem:lastassignedto
     email
     then set currentitem:assignedDate equal to Today
     then set currentitem:lastassigned equal to currentitem:assignedTo

You could also do your dates in a workflow as well instead of javascript - you'd need to add another hidden field to your list - LastStatus, for example, and do something like this to test whether the status field has changed:

if currentitem:taskStatus is not equal to currentitem:LastStatus
     if currentitem:taskStatus is equal to 'In Progress'
         set currentitem:DateInProgress equal to Today
     then set currentitem:laststatus equal to currentitem:taskstatus
0

You need a item event handler, something like this:

   public override void ItemUpdated(SPItemEventProperties properties)
   {
      if(properties.BeforeProperties["Status"]!=properties.AfterProperties ["Status"]){
         properties.ListItem["Date In Progress"]=DateTime.Now;
       }
   }
  • 1
    Let's add some null checks to the Before and After properties too – Robert Lindgren May 2 '13 at 10:15
-1

You can also achieve it using Out of Box Nintex Workflow. Just Add an App > Nintex Workflow.

Create new Variable of type Date/Time. Assign it value when created by configuring Set Workflow Variable. Assign that variable to any column of your list

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.