Hi all!
I'm trying to update the lastModified field for a Delivery template:
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@id"/>
</select>
</queryDef>);
var result = query.ExecuteQuery();
for each (var res in result) {
var delivery = nms.delivery.load(res.@id);
logInfo(delivery.lastModified);
delivery.lastModified = getCurrentDate();
delivery.save();
logInfo(delivery.lastModified);
}
In log I see old date and new one, after save():
But template still has old date:
Please help me find the problem
Solved! Go to Solution.
Views
Replies
Total Likes
The Syntax is correct, It works fine for attributes like delivery label, but for lastModified it is not updating with above structure.
Instead you can try the below script,
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@id"/>
</select>
</queryDef>);
var result = query.ExecuteQuery();
for each (var res in result) {
vars.newLastModified = getCurrentDate();
sqlExec("UPDATE NmsDelivery SET tsLastModified=$(ts) WHERE iDeliveryId=$(l)",vars.newLastModified,res.@id);
}
The Syntax is correct, It works fine for attributes like delivery label, but for lastModified it is not updating with above structure.
Instead you can try the below script,
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@id"/>
</select>
</queryDef>);
var result = query.ExecuteQuery();
for each (var res in result) {
vars.newLastModified = getCurrentDate();
sqlExec("UPDATE NmsDelivery SET tsLastModified=$(ts) WHERE iDeliveryId=$(l)",vars.newLastModified,res.@id);
}
Thanks for your answer. It's working correct!
But why did it work through SQL but does not work in the usual way?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies