Skip to main content
Level 2
Nov 6, 2023 10:35 PM UTC
Solved

How to retrieve values for the variable name and variable expression fields defined within delivery properties

Hi Team,

I would like to retrieve values for the variable name ([variables/var/@name]) and variable expression ([variables/var/expr]) fields stored in the nms:delivery schema using a queryDef. I have tried the following code. I am able to view the XML data for deliveryContent but d.varName and d.varExpr are blank:

 

var deliveryContent = xtk.queryDef.create(
<queryDef schema="nms:delivery" operation="select">
<select>
<node expr="[variables/var/@name]" alias="varName"/>
<node expr="[variables/var/expr]" alias="varExpr"/>
</select>
<where>
<condition expr = {"@id = '1000'"} />
</where>
</queryDef>
).ExecuteQuery();

logInfo("Variable XML: "+deliveryContent);

for each(var d in deliveryContent){
logInfo("Var Name: "+d.varName);
logInfo("Var Expr: "+d.varExpr);
}

 

Can anyone please help me populate the values for the above fields? Thank you in advance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
ParthaSarathy
ParthaSarathyAccepted solution
Community Advisor
Nov 7, 2023 3:22 AM UTC

Hi @anushka_rk ,

Use the below script, it will print varName and varExpr:

 

var query = xtk.queryDef.create( <queryDef schema="nms:delivery" operation="select"> <select> <node expr="@id"/> <node expr="[variables/var/@name]" alias="varName"/> <node expr="[variables/var/expr]" alias="varExpr"/> </select> <where> <condition expr = {"@id = '123456'"} /> </where> </queryDef> ); var record = query.ExecuteQuery(); for each (var d in record) { logInfo("vars.varName"+d.variables.varName); logInfo("vars.varExpr"+d.variables.varExpr); }

 

~  ParthaSarathy S

2 replies

ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
Nov 7, 2023 3:22 AM UTC

Hi @anushka_rk ,

Use the below script, it will print varName and varExpr:

 

var query = xtk.queryDef.create( <queryDef schema="nms:delivery" operation="select"> <select> <node expr="@id"/> <node expr="[variables/var/@name]" alias="varName"/> <node expr="[variables/var/expr]" alias="varExpr"/> </select> <where> <condition expr = {"@id = '123456'"} /> </where> </queryDef> ); var record = query.ExecuteQuery(); for each (var d in record) { logInfo("vars.varName"+d.variables.varName); logInfo("vars.varExpr"+d.variables.varExpr); }

 

Translate
~  ParthaSarathy S
Level 2
Nov 7, 2023 2:49 PM UTC

Hi @parthasarathy 
It worked. Thank you.

Kind Regards,

Anushka 

Translate