2

List 1 "Posts", fields

 Title      body   #comments     modified

in this list #comments fields is look up from another list Comments:

List 2 "Comments", fields

title     body   comments      post tilte modified

in this list post "title" field is look up from list 1.

Now I have to form a join SPQuery to get a comments list modified field.

SPList listFaculty = web.Lists["Posts"];
            SPQuery query = new SPQuery();
            query.Query = "<where></where>";
            query.Joins = "<join Type='Left' ListAlias='Comments'>" + "<eq><fieldref Name='Title' RefType='ID' />" + "<fieldref List='Comments1' Name='ID' /></eq></join>";
            query.ProjectedFields = "<field Name='Modified1' Type='Lookup' List='Comments1' ShowField='Modified'/>"; 
            query.ViewFields = "<fieldref Name='Modified1' />";
            SPListItemCollection lists = listFaculty.GetItems(query);

I'm getting error

Value does not fall within the range

What am I doing wrong?

  • does it work without the join/projectedfields? – Gwny Jul 31 '14 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.