Script to uncheck a checkbox in knowledge article when End date is crossed

MohammedYaseen
Tera Expert

Hi All,

 

I have a requirement where i have a checkbox field in Knowledge article - Exemptions

Also i have a Exemption End date field. Whenever the Exemption end date is crossed, the condition should uncheck the Exemptions checkbox in the article.

 

If any solution already available, please do share. Thanks

 

Thanks,

Yaseen

1 ACCEPTED SOLUTION

Ayushi12
Mega Sage

HI @MohammedYaseen 
You can create a schedule job that run daily and will check the records if for any record Exemption end date is crossed it will uncheck field.
refer: var gdt = new GlideDateTime();
var date = gdt.getLocalDate(); //Get today's date
var exedate =current.<date field name> ; //Get Exemption end date
if (exedate < date ) {
current.<checkbox field name>= false;  //Uncheck Exemptions checkbox
}

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."

Thank You!

 

View solution in original post

4 REPLIES 4

Community Alums
Not applicable

Hi @MohammedYaseen,

can share a your script with us? so that will support on it. OR try following script in BR.

 

var currentDate = new GlideDateTime();
if (current.exemption_end_date && current.exemption_end_date < currentDate) {
current.exemptions = false; 
}

MohammedYaseen
Tera Expert

Thanks @Community Alums . I will try this and let you know

Ayushi12
Mega Sage

HI @MohammedYaseen 
You can create a schedule job that run daily and will check the records if for any record Exemption end date is crossed it will uncheck field.
refer: var gdt = new GlideDateTime();
var date = gdt.getLocalDate(); //Get today's date
var exedate =current.<date field name> ; //Get Exemption end date
if (exedate < date ) {
current.<checkbox field name>= false;  //Uncheck Exemptions checkbox
}

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."

Thank You!

 

Thanks @Ayushi12