Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm creating a SharePoint 2010 application called HR Learning And Development. Basically it's an application to manage every employee trainings. Much like a college environment. I have a SharePoint Lists named Training and Training Session. One training can have multiple sessions. The Training Session lists have Trainer, Start-date and Status column among other things. Employee who wants to enroll into this training would have to subscribe it.

The Training Session list should behave as follows :

  • Status = New -> when a training session is just created
  • Status = In Progress -> when the Start-date > DateTime.Now
  • Status = Completed -> when the End-date <= DateTime.Now

Could you guys help me on how to solve this things.

Your help is very much appreciated. Thanks

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

Other than workflow or a timer job I can't think of a way you could do this. I suppose you could do it as part of some kind of batch process outside of SharePoint (i.e. not a timer job, but probably wouldn't recommend that).

For workflow, you could develop a simple workflow in SPD that launches when the item is created (...we'll assume the default value of Status is New so nothing needs to be done to set that programatically). You would then set it up something like this:

  1. Use Find Interval Between Dates action to calculate the difference between the Start Date and Today in days
  2. Use Find Interval Between Dates action to calculate the difference between the End Date and Today in days.
  3. Use the Pause for Duration action to pause the workflow for the days you calculated in step 1.
  4. Use the Set Field in Current Item action to set the Status to In Progress.
  5. Use the Pause for Duration action to pause the workflow for the days you calculated in step 2.
  6. Use the Set Field in Current Item action to set the Status to Completed.

The only downside to this approach is you will have a number of long-running in-flight workflow instances in your system. I wouldn't be concerned with this unless you anticipate having 10's of thousands of these items "active" (i.e. Today < End Date) at any given time.

For a timer job, you'd have to create it, deploy it, and register it to run within the scope of the site where you host this list. As executed you'd have to run some CAML queries to find the candidate rows to have their Status updated.

share|improve this answer
add comment

Workflow is the best approach to implement this scenario. You can create a simple workflow using Visual Studio which you can attach to the list and trigger the workflow on Item created and Updated and when the item is added the status is set to New. After that you can include a code activity where you can check the logic to see if task is started or Not. Based upon that you can change the status to In-Progress. Then you can have a While loop inside which you can have an On-Task Changed activity where you can check the logic for task completed.

You can see the videos provided in the below link which will facilitate you in the implementation in-case you are new to workflows.

http://www.sheltonblog.com/archive/2007/11/04/series-of-sharepoint-workflow-how-to-videos.aspx

All the Best ! Hope it helps.

Regards, Geetanjali

share|improve this answer
add comment

If you're looking to automate the the status updating process, in the scenario you described above, this screams workflow to me. When an item is created, the workflow sets the status to New (which can be avoided if you set that to the default value of the choice column) then waits until the start time and sets the status to In Progress. It then waits until the end time and sets the status to Completed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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