Trigger an Sla based on a date

simaoG
Tera Contributor

Hi All,

I have a requirement where I need to trigger an SLA with Target = Resolution to ensure that it is triggered on the same date as the value of a variable (on catalog item) for example if i choose next monday  the Sla has to start on that specific date.

7 REPLIES 7

 The Sla must take the date that  i mentioned in my variable u_due_date(type date)  when i make the request.

i have tried to do a Business rule in order to get the value of my variable but it doesn't work

 

here is the BR 

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

        var catalogItemValue = current.catalog_item.u_due_date; // u_due_date is the variable

       var duration = new GlideDateTime(catalogItemValue);
      // duration.addDaysUTC();
       duration.addHoursUTC(12);

        var schedule = new GlideSchedule("U - 8-18");
        duration = schedule.whenNext(duration);


            current.sla.target = duration;

                  var slaName = 'Advens - Request P1 - GTR'; // the name of my SLA
                  var mySla = new GlideRecord('contract_sla');

                     mySla.addQuery = ('name' , slaName);
                     mySla.query();

                          if (mySla.next()) {

                             mySla.u_due_date = current.catalog_item.u_due_date;
                             mySla.duration = duration.getNumericValue();

                               gs.info("J'ai récupéré " + slaName + ", yesss !");

                         } else {

                          gs.info("Aucun Sla pour " + slaName);
                    }

   

})(current, previous);

 

Jugmaz
Kilo Sage

 current.catalog_item.u_due_date

if i'm not totally mistaken, variable values are in variables, so for ex. ritm they are:

current.variables.u_due_date

please check: https://www.servicenow.com/community/developer-articles/how-to-easily-access-ritm-variables-via-scri...

 

Abhishek Kr47
Tera Contributor

Hey @simaoG , i have the same requirement. Did you get the solution