3

I've 3 lists (Agistors, Paddocks, Horses) Horse list has lookup field to Agistor list & lookup field to Paddock list (see Attachment) i'm looking for a solution using CSOM (javascript) to automatically

  1. look at a list of agistors and see which horses they own
  2. look at a list of paddocks and see which horses are in the paddock here's column names
  3. look at a list of paddocks and see which horses are in the paddock

Column Names:

  • Agistors: ID
  • Horses: Horse_x0020_name, Owned_x0020_by_x0020_agistor (FK Agistor list), Current (FK Paddocks list)
  • Paddocks: Paddock_x0020_name

I've used caml query for case 1 but it doesn't work

camlQuery.set_viewXml
("<View>
    <Query></Query>
        <ProjectedFields>
            <Field Name='horse' Type='Lookup' List='Horses' ShowField='Horse_x0020_name' />
        </ProjectedFields>
        <Joins>
            <Join Type='INNER' ListAlias='Horses'>
                <Eq>
                    <FieldRef Name='ID' RefType='Id'/>
                    <FieldRef List='Horses' Name='Owned_x0020_by_x0020_agistor'/>
                </Eq>
            </Join>
        </Joins>
        <ViewFields>
            <FieldRef Name='horse'/> 
            <FieldRef Name='ID' />
        </ViewFields>
 </View>");

See Attachment

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.