Schedule Entry Start/End Date

solonxu
Kilo Expert

Hi, Community,

I am trying to get the   start/end date in current year, for example, I have a schedule set as:

find_real_file.png

If I call schedule_entry.start_date_time, it returns '2014-10-21', which I actually want 2016-10-21.

Does anyone know if there is any oob function I can use to get the updated data? Or I have to calculate through custom script?

Any suggestion would be appreciated.

6 REPLIES 6

My understanding of schedules is that they are used with/for SLA's and inactivity monitors. I don't think this is necessarily the best way to approach what you are trying to solve.



I'm just throwing stuff out here, others can weigh in, but I would do this kind of thing via data lookup rules or business rule. In this specific circumstance you could do it without scripting, by creating an on insert business rule. You could then specify in the condition builder if the Opened (opened_at) or created was on or between two date times. However, you would run into the same problem of having to maintain these dates by modifying them to reflect the current year, or scripting it.



This is my "back of the envelope" idea, but if I HAD to write a script, I would do something similar to the below and put it in an insert business rule.



//First we need the list of day/month that will be specicifed. Make sure day and month are two digits separated by a "-".


var highPriority = ["12-25","12-26","12-27","12-28","12-29","12-30",


                                                        "12-31","01-01","01-02","01-03","07-04","07-05",


                                                        "07-06", "07-07","08-01","08-02","08-03","01-22"];


//dayMonth will return "dd-mm" for the current date. For example, today it would be "01-22"


var today = new GlideDate().toString();


var dayMonth = today.substring(today.length() - 5);



//Check the contents of highPriority array to see if dayMonth matches


for (i=0;i<highPriority.length;i++){


      if (highPriority[i] == dayMonth)


              {


                      //Found a match, set the field and exit the loop


                      current.urgency = 1;


                      break;


              }


      }




In my example I set urgency to be high, but this would be whatever you needed.



Can anyone weigh in on this? I feel like there might/should be a way to do this OOTB.


Nana5
Mega Guru

Hi Solon,


I think u can increase the year.


For catalog i use to increase 30 days based on current day using below business rule.Please have a look it may helps for u.



function onBefore(current, previous) {


    //This function will be automatically called when this rule is processed.


    var anActualDate = new GlideDateTime();


anActualDate.setDisplayValue(current.request_item.variable_pool.u_employee_leaving.getDisplayValue());


var datePlusOne = anActualDate.getNumericValue();


datePlusOne += (1000*60*60*840);


current.due_date.setDateNumericValue(datePlusOne);


}