Expand my Community achievements bar.

SOLVED

Create a timestamp after a field is updated

Avatar

Level 4

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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