Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the status of an approval workflow of item using sharepoint object model?

There is a list on which an approval workflow is associated,workflow starts when an item is added.The list is having anonymous access so anyone can enter an item,but the item needs to be approved by an approver.Hence,each item will have a status(e.g. approved,rejected etc.).

Now,I am creating a visual webpart.I want to display the list items in a grid.But I need to display only those items which are approved.I am using sharepoint object model,How can I filter the items based on the approval status.

Thanks

like image 883
user439613 Avatar asked Oct 19 '10 04:10

user439613


1 Answers

The name of the Workflow Status field is usually first 8 alphanumeric characters of the name of your Workflow. The value of Approved is 16. So selecting only approved items should look something like this:

string caml = @"<Where><Eq><FieldRef Name='MyApprov' /><Value Type='WorkflowStatus'>16</Value></Eq></Where>";
SPQuery query = new SPQuery();
query.Query = caml;
SPListItemCollection items = list.GetItems(query);
like image 53
Rich Bennema Avatar answered Oct 05 '22 11:10

Rich Bennema