Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

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

1 Reply

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