Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

LastModified for Template

Avatar

Level 2

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(): 

MariaKonstantinova1995_0-1678799751795.png

 

But template still has old date:

MariaKonstantinova1995_1-1678799910875.png

 

Please help me find the problem

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @MariaKonstantinova1995 ,

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);
   
  }

 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @MariaKonstantinova1995 ,

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);
   
  }

 

Hi @ParthaSarathy 

 

Thanks for your answer. It's working correct!

But why did it work through SQL but does not work in the usual way?