Script Include not being processed properly by query

Jeffrey Siegel
Mega Sage

 Based on:  https://www.servicenow.com/community/platform-analytics-articles/building-scripted-date-time-conditi...

 

i created all the relevant script includes and adjusted the business rule accordingly... however i noticed they didnt account for a modified week start based on a the system property: 

glide.ui.date_format.first_day_of_week 
 

so i modified their script include to be:

 

function weeksAgoStart(n){
var gdt = new GlideDateTime();
var weekStart = 0;
var weekStart2 = gs.getProperty('glide.ui.date_format.first_day_of_week', "2");
weekStart = parseInt(weekStart2, 10);
//weekStart = 1;  //THIS WILL ONLY WORK IF NOT COMMENTED OUT


//SET THE DATE
gdt.addWeeksLocalTime(n * -1);
var weekCalc = (weekStart - 1);
gdt.addDaysLocalTime((gdt.getDayOfWeekLocalTime() - weekCalc) * -1 );

//CORRECT THE TIME
gdt.setDisplayValueInternal(gdt.getDisplayValueInternal().split(' ')[0] + " 00:00:00");

//RETURN THE DATE

return gdt;
}

 

 however as my commented line states, the system will not process this if the system property is pulled in, i have to manually set the value from the system property to the variable in the script include for it to work properly via a dashboard widget or via a click through list filter....

if i run the code (via copy and paste) or the Script Include through a background script, it works the same way either with my hard coded 1 or via the pull in from the system property. so i'm not sure why the query is failing to pull this properly,  does anyone have any ideas? 

 

I know my environment wont change, so i can Hard Code the start of week, but i shouldn't have to, this is just bugging me!!

0 REPLIES 0