Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Query Database

Avatar

Level 3

I am trying to query the database through a script in a web app, but when providing the country location in the database, it is throwing an error. The folder is gmlocation/country under recipients. This is the error below.

Attribute 'country' unknown (see definition of schema 'Recipients (nms:recipient)'). XTK-170036 Unable to parse expression '@country='CAN''. SOP-330011 Error while executing the method 'ExecuteQuery' of service 'xtk:queryDef'.

 

Here is an sample of the script I am trying to query.

var query = xtk.queryDef.create(
  
  <queryDef schema="nms:recipient" operation="getIfExists">
    
    <select>
   
      <node expr="@email"/>
      
      <node expr="@id"/>
    
    </select>
   
    <where>
    
    <condition expr={"@email='"+ctx.recipient.@email+"'"}/>
    <condition expr={"@sourceType='Media'"}/>
    <condition expr={"@country='CAN'"}/>
     
    </where>
    </queryDef>
3 Replies

Avatar

Community Advisor

Hello @StrawHatM23,

country is to found under [location/@countryCode] and it is ISO A2 not A3 so you condition should be

 

 

 

<condition expr={"[location/@countryCode]='CA'"}/>

 

 

 

 

Marcel Szimonisz

MarTech Consultant
for more tips visit my blog
https://www.martechnotes.com/

Avatar

Level 3

 I am still receiving an error. Here is a screenshot of my configure list. 

I tried using 

<condition expr={"[gmLocation/@country]='CAN'"}/>

 

Screenshot (24).png

Avatar

Employee Advisor

Hello @StrawHatM23 
Must be missing something.
Please share your latest error, and if possible share the schema definition for [gmLocation/@country]

Generating queryDef query should be simple with below steps:
1/ Navigate to schema; Data tab
2/ Use Advanced filter and apply your query filter

3/ Ensure the results are loaded

4/ Re-open the filter; Right-click and choose Edit XML source...

Kishore_Padamata_0-1653065519425.png

Hope this helps!