LastModified for Template | Community
Skip to main content
Level 2
March 14, 2023
Solved

LastModified for Template

  • March 14, 2023
  • 1 reply
  • 794 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ParthaSarathy

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

 

1 reply

ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
March 14, 2023

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

 

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
Level 2
March 14, 2023

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?