Create a timestamp after a field is updated

RaulOcana

28-02-2020

Hi guys,

 

It is possible to insert a date (in a new field) once a recipient's field is updated, for instance, the blacklist field? So we can check when a user opted-in or opted-out?

 

Thank you!

 

Regards,

Raúl

Accepted Solutions (1)

Accepted Solutions (1)

Milan_Vucetic

MVP

29-02-2020

Hi @RaulOcana ,

 

recipient table has a native link to Modified by where datetime is updated when any field is changed.

In case you need a new column you can define a new attribute/column like this and field will contain sysdate when record was inserted (Oracle).

milanv69354962_0-1583006575506.png

 

If you are using web app (for email opt in/out) you can use JS like this:

 

if ( ctx.vars.recipientId == "" || ctx.vars.recipientId == undefined || ctx.vars.recipientId == null ) {

ctx.recipient.@xtkschema="nms:recipient";
ctx.recipient.@_operation="update";
ctx.recipient.@_key="@id";
ctx.recipient.@lastBlackListEmail = (new Date()).toISOString();

if ( ctx.currentBlackList.@blackListEmail != ctx.recipient.@blackListEmail ) {
xtk.session.Write(ctx.recipient)
}

}

 

Regards,

Milan

 

Answers (0)