Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

To mark checkbox to true depending on valid to date.

Sam Hanson
Tera Contributor

Hi Peeps,

I have active field -checkbox- on cmn_cost_center table. Now I want to make checkbox to true depending on valid to date. For that reason I created the below BR

Name : Set active to True 

AFTER - Insert, Update.

 

(function executeRule(current, previous /*null when async*/) {

// Get the "valid to" and current date
var validToDate = new GlideDateTime(current.valid_to);
var currentDate = new GlideDateTime();

// Check if "valid to" date is in the future
if (validToDate > currentDate) {
// Set the "active" field to true
current.active = true;
}

})(current, previous);
 
I have 2 questions here
1) do I need to create any conditions on this BR.
2) do I need to create a fix script to mark the existing cost centers active??
 
can anyone give me the best practice here

 

5 REPLIES 5

Will this work?

JamesChun_0-1712093229423.png

 

valid_toRELATIVEGT@minute@ahead@0