I have to filter RelatedItemID column from workflow task list using CAML query to get only those records that match the MAIN itemID from its corresponding main list. How do I achieve this? I tried the below query and it's surprising to know that it doesn't work, rather the query returns all records irrespective of the below filter that applied.

enter image description here

1 Answer 1


Per my test, I could reproduce you issue on my end.

Seems that the character ' cannot be encoded correctly, try to replace it with " and remove the slash \. Also you need to change the Eq to Contains.

Here is my demo for you:

   camlQuery.ViewXml =
               <Where><Contains><FieldRef Name='RelatedItems' /><Value Type='RelatedItems'>[{&quot;ItemId&quot;:14,&quot;WebId&quot;:&quot;c1220a37-046e-4c95-9e32-803fd4d54caa&quot;,&quot;ListId&quot;:&quot;8bb17903-679e-4ef9-9826-d61b19289703&quot;}]</Value></Contains></Where> 
             <ViewFields><FieldRef Name='RelatedItems' /></ViewFields> 
  • Thanks you so much Michael. This solved the issue which i was facing....
    – anymo
    Commented Mar 31, 2020 at 7:01
  • You could accept my answer if it helps you:) Commented Mar 31, 2020 at 8:20

Your Answer

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

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