Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to auto populate due date filed on problem and problem task table

pvv1045330
Tera Contributor

Hi All,

 

I need to auto populated due date value on problem and problem task table based on priority values.

 

ex: if priority is 1 due date is +7days need to populated on due date field 

  2. if priority is 2 due date is +10 days need to populated on due date field 

3. if priority is 3 user will be enter the date manual, if not fill make a field is mandatory.

 

How can we write script for above scenario 

 

 

  

2 REPLIES 2

Sirri
Tera Guru

Hi,

 

Use GlideDateTime based on your conditions.

pvv1045330
Tera Contributor

if priority is 3 or 4 user fill the due date manual, if he not make mandatory field on problem and problem task.

How can we make due date field mandatory if problem 3or 4

 

I am using below script

var datevalue = current.priority;
 
    var days1;
 
    if (datevalue == '1') {
        days1 = 14;
 
    } else if (datevalue == '2') {
        days1 = 2;
    } 
else if (datevalue == '3' || datevalue == '4' || datevalue == '5') {
        current.setValue('due_date','');
 
    }
if(days1){
    
    var ed = new GlideDateTime();
 
    ed.addDays(days1);
    current.due_date = ed;
}