SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having trouble using the Join via Caml. In a way, I'm having trouble working with 1 field, that is "new window" that the field type is boolean.

My code looks like this:

SPQuery oQuery = new SPQuery();
StringBuilder sbJoin = new StringBuilder();
StringBuilder sbProj = new StringBuilder();
StringBuilder sbQuery = new StringBuilder();

using (SPSite siteCollection = new SPSite("http://localhost/"))
    using (SPWeb web = siteCollection.OpenWeb())
        SPList oList = web.Lists["shortcuts users"];
        SPListItemCollection items = null;

        sbJoin.Append("<Join Type='INNER' ListAlias='shortcuts'>");
        sbJoin.Append("<FieldRef Name='shortcut' RefType='Id'/><FieldRef List='shortcuts' Name='ID'/>");

        sbQuery.Append("<Eq><FieldRef Name='user' /><Value Type='Number'>1</Value></Eq>");
        sbQuery.Append("<OrderBy><FieldRef Name='order' Ascending='True' /></OrderBy>");

        sbProj.Append("<Field Name='shortcutName' Type='Lookup' List='Atalhos' ShowField='Title'/>");
        sbProj.Append("<Field Name='shortcutLink' Type='Lookup' List='Atalhos' ShowField='link'/>");
        sbProj.Append("<Field Name='shortcutNewWindow' Type='Boolean' List='Atalhos' ShowField='newWindow'/>");
        sbProj.Append("<Field Name='AtalhoContentTypeId' Type='Lookup' List='Atalhos' ShowField='ContentTypeId' />");

        oQuery.ViewFields = "<FieldRef Name='Title'/><FieldRef Name='order'/><FieldRef Name='shortcutName'/><FieldRef Name='shortcutLink'/><FieldRef Name='shortcutNewWindow'/>";
        oQuery.Joins = sbJoin.ToString();
        oQuery.Query = sbQuery.ToString();
        oQuery.ProjectedFields = sbProj.ToString();

        items = oList.GetItems(oQuery);

        if (items.Count > 0)
            foreach (SPListItem item in items)
                Console.WriteLine("Name: {0}, order: {1} - shortcut Name: {2}, shortcut Link: {3} shortcut New Window: {4}",

            Console.WriteLine("Total: {0}", items.Count);


The problem is in this line:

sbProj.Append("<Field Name='shortcutNewWindow' Type='Boolean' List='Atalhos' ShowField='newWindow'/>");

If I use the boolean type of the field as it returns this error: 0x80070057

Now if I use the field type as another Lookup returns this error: Value does not fall within the expected range

What type of field, I have to use in order to function?

share|improve this question

The ListAlias in the Join clause should be the same as the List of your projected fields.

Similar error

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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