I'm trying to select users ids from custom tasks lists. All users are in one SP Group and I need to collect users Ids that doesn't have tasks.

query.Query = string.Format("<And><Membership Type='SPGroup' ID='{0}'><FieldRef Name='AssignedTo'/></Membership><Neq><FieldRef Name='AssignedTo'/><Value Type='Integer'><UserID/></Value></Neq></And>", web.SiteGroups[Groups.CodeConductGroup].ID);
    var list = web.Lists[Lists.CodeConductTasks].GetItems(query);

Unfortunately this query returns me users ids that has tasks. Could anyone help to make it work in a right way?

1 Answer 1


I don't think you can do this in pure CAML. What you can do is take the result of your CAML and then iterate over the group's Users and see who is there but not returned in the CAML, though if some of the Users are AD groups that might be a problem.

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.