Monday, June 30, 2008

Correct way to complete task from code in workflow

Hi All,

If you are working with windows workflow foundation, then you might be knowing that you can complete the task by assigning Completed status for workflow item or making the percentage 100.

But there is possibility where task is actually not completed and you set the percentage to 100 or even you set the status to Completed and percentage shows you only 95% done.

This is not the correct way to do it. There is one interesting thing in the code.

See SPBuiltInFieldId enumeration which will give you list of all hidden fields in MOSS that is actually internally referred by MOSS. Sometimes there are certain columns that is having title different and you have to work with them with different name.

Back to our point, this is the way to actually complete the task.

Hashtable data = new Hashtable();
data[SPBuiltInFieldId.Completed] = "TRUE";
data[SPBuiltInFieldId.PercentComplete] = 1;
data[SPBuiltInFieldId.TaskStatus] =
new CultureInfo( (int)taskListItem.Web.Language, false),
new object[0]);

That's it. you are done with your job.

This good solution is given at this link

No comments:

Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to