0

I need to find all items from Tasks history (Workflow history) list from SharePoint 2013, but I don't manage to get it exactly right, I have managed to get all items and no items at all.

Any idea, what might be wrong? Since there are items on list with those values:

enter image description here

Code:

     List workflowList = context.Web.Lists.GetById(new Guid("{1D356251-D55C-4D7A-97E1-11063B125350}"));

     CamlQuery qryWF = new CamlQuery();
     qryWF.ViewXml =
string.Format(@"<View>
    <Query>
       <Where>
          <And>
             <Contains>
                <FieldRef Name='List' />
                <Value Type='Lookup'>{0}</Value>         
            </Contains>  
            <Eq>
                <FieldRef Name='Item' />
                <Value Type='Lookup'>{1}</Value>
                </Eq>
            </And>
        </Where>
    </Query>
</View>", "aacd3fe2-40a1-4ed3-b5a5-41e00a669848", 76);

      ListItemCollection workflowListItems = workflowList.GetItems(qryWF);
      context.Load(workflowListItems);
      context.ExecuteQuery();
2
  • Remove <View> and <query> from the CamlQuery.
    – Amit
    Mar 27, 2017 at 10:28
  • 1
    Problem was with types, see answer below
    – Taurib
    Mar 27, 2017 at 10:44

1 Answer 1

2

List and Item columns in the Workflow History list has types Single Line of Text and Integer respectively. Please verify.

So Query will be:

<View>
    <Query>
       <Where>
          <And>
             <Contains>
                <FieldRef Name='List' />
                <Value Type='Text'>{0}</Value>         
            </Contains>  
            <Eq>
                <FieldRef Name='Item' />
                <Value Type='Integer'>{1}</Value>
                </Eq>
            </And>
        </Where>
    </Query>
</View>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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