I need to run the schedule report periodically every one hour from monday 6 am to saturday 12:30 pm ist

kiranreddy
Kilo Contributor

        I need to run the schedule report periodically every one hour from monday 6 am to saturday 12:30 pm ist

Below script is not working properly ,could you please help me on this ,its a priority for me.

I think wrong with the diffStart and diffEnd , instead of dateDiff   is there any alternate script for this to pass time directly.

Script :

var strStart = gs.now().toString() + " 06:00:00";  

var strEnd = gs.now().toString() + " 12:30:00";

var start = new GlideDateTime(strStart);  

var end = new GlideDateTime(strEnd);  

var now = new GlideDateTime(gs.nowDateTime());  

var diffStart = gs.dateDiff(now.getDisplayValue(), start.getDisplayValue(), true);  

var diffEnd = gs.dateDiff(now.getDisplayValue(), end.getDisplayValue(), true);  

var dayOfWeek = new GlideDateTime().getDayOfWeekLocalTime();  

 

if ((dayOfWeek > 0 && dayOfWeek <=6) && (diffStart < 0 && diffEnd > 0))  

answer = true;  

else    

answer = false;

Thanks & Regards,

Kiran

4 REPLIES 4

Chuck Tomasi
Tera Patron

Hi Kiran,



For what it's worth, consider using live data on a home page for such information.



When ever someone says they need a scheduled report, it tells me that the reader is always getting out of date data and way too often. If they get it every hour, it's going to be ignored (I know I would ignore it after a time.)


I agree with what Chuck is saying.   We have ones that are scheduled to go out daily and people ignore them.   I'd imagine it's only a matter of time before the Outlook rule is set up having this routed right to a folder to be forgotten.



Do you have a use case in which this request sounds a bit more valid?


kiranreddy
Kilo Contributor

Hi Chuck,



we generated report for Business Support on incident table based on (State =New and Response Received > 4 hours ago)



if   match the conditions then report will triggered or omit if no records .



so for this report I need to schedule periodically   /interval 1 hour and it should be run in between Monday 6 AM   to Saturday 12:30 PM in IST.




Regards


Kiran K


Hi Kiran,



This is where I put on my analyst hat and push back on what I feel is a seemingly innocent requirement and offer them something better.



I'm guessing if you asked these people if they would like a report mailed to them once an hour OR be able to login and see live data that they can drill in to   and view in their own personal way, they're going to choose the latter.



Based on my >30 years in IT, I can tell you frequent reports get ignored really quickly and the effort you put in to a solution to create a custom schedule for this is going to soon fade. Even from my own personal experience, I have email rules that file things away for me and I'm not looking at them as once expected, but I always know I can go to a   ServiceNow instance and see the live data when I need.



Encourage them to use their mobile devices too!



Mobile app UI