Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. SharePoint
  4. CAML Joins in Javascript

CAML Joins in Javascript

Scheduled Pinned Locked Moved SharePoint
sharepointjavascriptdatabasehelp
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jay Royall
    wrote on last edited by
    #1

    Hi, I'm fairly new to developing apps for Sharepoint so please go easy! I'm having a problem joining two lists using CAML in Javascript. What I'm trying to do may not even be possible but from the research I've done so far I believe it should be, but I'm obviously going wrong somewhere. There are two lists in my app that are joined by a lookup column. The parent list is named TransactionHeader and the child list is named TransactionItems. For every item in the TransactionHeader list there will be one or more related items in the TransactionItems list. What I'm trying to do is retrieve items from the TransactionItems list but join to the TransactionHeader list so that I can also retrieve related data. The CAML I'm using is as follows:

    var query;
    query += "<View>";
    query += " <ViewFields>";
    query += " <FieldRef Name='ItemStatus' />";
    query += " <FieldRef Name='ItemDate' />";
    query += " <FieldRef Name='myReviewedBy' />";
    query += " </ViewFields>";
    query += " <ProjectedFields>";
    query += " <Field Name='myReviewedBy' Type='Lookup' List='myTransactionHeaders' ShowField='ReviewedBy' />";
    query += " </ProjectedFields>";
    query += " <Joins>";
    query += " <Join Type='Left' ListAlias='myTransactionHeaders'>";
    query += " <Eq>";
    query += " <FieldRef Name='TransactionHeader' RefType='Id' />";
    query += " <FieldRef List='myTransactionHeaders' Name='ID'>";
    query += " </Eq>";
    query += " </Join>";
    query += " </Joins>";
    query += "</View>";

    This CAML always results in a 'Cannot complete this action' message being displayed. A little more information in case it's important; after building the query I'm loading the TransactionItems list like so:

    var ctx = new SP.ClientContext.get_current();
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml(myCaml);
    var list = ctx.get_web().get_lists().getB

    B 1 Reply Last reply
    0
    • J Jay Royall

      Hi, I'm fairly new to developing apps for Sharepoint so please go easy! I'm having a problem joining two lists using CAML in Javascript. What I'm trying to do may not even be possible but from the research I've done so far I believe it should be, but I'm obviously going wrong somewhere. There are two lists in my app that are joined by a lookup column. The parent list is named TransactionHeader and the child list is named TransactionItems. For every item in the TransactionHeader list there will be one or more related items in the TransactionItems list. What I'm trying to do is retrieve items from the TransactionItems list but join to the TransactionHeader list so that I can also retrieve related data. The CAML I'm using is as follows:

      var query;
      query += "<View>";
      query += " <ViewFields>";
      query += " <FieldRef Name='ItemStatus' />";
      query += " <FieldRef Name='ItemDate' />";
      query += " <FieldRef Name='myReviewedBy' />";
      query += " </ViewFields>";
      query += " <ProjectedFields>";
      query += " <Field Name='myReviewedBy' Type='Lookup' List='myTransactionHeaders' ShowField='ReviewedBy' />";
      query += " </ProjectedFields>";
      query += " <Joins>";
      query += " <Join Type='Left' ListAlias='myTransactionHeaders'>";
      query += " <Eq>";
      query += " <FieldRef Name='TransactionHeader' RefType='Id' />";
      query += " <FieldRef List='myTransactionHeaders' Name='ID'>";
      query += " </Eq>";
      query += " </Join>";
      query += " </Joins>";
      query += "</View>";

      This CAML always results in a 'Cannot complete this action' message being displayed. A little more information in case it's important; after building the query I'm loading the TransactionItems list like so:

      var ctx = new SP.ClientContext.get_current();
      var camlQuery = new SP.CamlQuery();
      camlQuery.set_viewXml(myCaml);
      var list = ctx.get_web().get_lists().getB

      B Offline
      B Offline
      Beginner Luck
      wrote on last edited by
      #2

      This error message "Cannot complete this action" mean you CAML query statement is wrong somewhere!! Just only check your query :thumbsup:

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups