Query Database | Community
Skip to main content
Level 3
April 27, 2022
Question

Query Database

  • April 27, 2022
  • 1 reply
  • 1234 views

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>
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Marcel_Szimonisz
Community Advisor
Community Advisor
April 28, 2022

Hello @justinbr17,

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/

Level 3
April 28, 2022

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

I tried using 

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

 

Kishore_Padamata
Adobe Employee
Adobe Employee
May 20, 2022

Hello @justinbr17 
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...

Hope this helps!