Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

How to use Joins in queries in js files

Avatar

Level 2

Hi there,

 

I am trying to query data from javascript like below:

 

var query = NLWS.xtkQueryDef.create(
  {queryDef: {schema: "nms:recipient", operation: "select", 
    select: {
        node: [{expr: "@id"},
               {expr: "@label"},
               {expr: "@internalName"}] 
    }, 
    where: {
      condition: [{expr: "@id='16'"}]
    }
  }})

 

So for the above query, if I have another table which is nms:userEmail. And I want to inner join this table with the current one(which is the one that shows above in the js code(nms:recipient)), and get the joined table. How can I do that here? What the query should be like?

 

Thank you!

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi,

 

Is the join defined in the schema already? In that case you should be able to reference attributes of the linked schema in the query, either in selected nodes or conditions:

 

var query = NLWS.xtkQueryDef.create(
  {queryDef: {schema: "nms:recipient", operation: "select", 
    select: {
        node: [{expr: "@id"},
               {expr: "@label"},
               {expr: "@internalName"},
{expr: "linkToOtherResource/@linkedAttribute"}] }, where: { condition: [{expr: "@id='16'"}] } }})

 

Regards

View solution in original post

5 Replies

Avatar

Correct answer by
Level 4

Hi,

 

Is the join defined in the schema already? In that case you should be able to reference attributes of the linked schema in the query, either in selected nodes or conditions:

 

var query = NLWS.xtkQueryDef.create(
  {queryDef: {schema: "nms:recipient", operation: "select", 
    select: {
        node: [{expr: "@id"},
               {expr: "@label"},
               {expr: "@internalName"},
{expr: "linkToOtherResource/@linkedAttribute"}] }, where: { condition: [{expr: "@id='16'"}] } }})

 

Regards

Avatar

Level 2
Hi, jonasn, thx so much for replying me!, I have added sth like "expr: "emailInfo/@email]", and the externalJoin is in my schema. But I got the error which says :"The node of path '/' is not stored as an independent SQL field, UNable to use it as a filtering criteria in a query". Do you know how this error comes?

Avatar

Level 2
Is there anything wrong if I use '/' in the expr ?

Avatar

Level 2

@kattyice, make sure that your node expression is wrapped in square brackets: 

{expr: "[linkToOtherResource/@linkedAttribute]"}