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
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With