1

I want to use left outer join in my caml query in java script. I am little bit confused how to use joins. Please anyone explain an easy example of left outer join query in caml.

1

There is an excellent tool available to help with complex CAML queries in JS especially when working with joins: https://camljs.codeplex.com/

Joining lists via CamlJs is very easy. Here's the example:

var query = new CamlBuilder()
.View(["Title","Country","Population"])
.LeftJoin("Country","Country").Select("People","Population")
.Query()
.Where()
.NumberField("Population").LessThan(10)
.ToString();

Camljs will automatically generate the appropriate CAML query for you. So the resulting generated CAML query will be the following:

<View>
<ViewFields>
    <FieldRef Name="Title" />
    <FieldRef Name="Country" />
    <FieldRef Name="Population" />
</ViewFields>
<Joins>
    <Join Type="LEFT" ListAlias="Country">
        <Eq>
            <FieldRef Name="Country" RefType="ID" />
            <FieldRef Name="ID" List="Country" />
        </Eq>
    </Join>
</Joins>
<ProjectedFields>
    <Field ShowField="People" Type="Lookup" Name="Population" List="Country" />
</ProjectedFields>
<Query>
    <Where>
        <Lt>
            <FieldRef Name="Population" />
            <Value Type="Number">10</Value>
        </Lt>
    </Where>
</Query>

Your Answer

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

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