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.
Solved! Go to Solution.
Views
Replies
Total Likes
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);
}
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);
}
Views
Likes
Replies