The CreatorCon Call for Content is officially open! Get started here.

Create Trend Definitions?

ctsmith
Mega Sage

Is it possible to create new trend definitions to use in reports that use the trend condition in the filter?  I can't find the table that would store these trend definitions.  In this case, create a trend on 1/2 hour increment.

Thanks!

find_real_file.png

8 REPLIES 8

Yeah, we'll see.  It works perfect on background script, but adding the function as a filter condition that calls the script include shows a warning in the log that appears to be a known error.  So, I have a case open with HI to see when the fix is.

I tried your idea on the dynamic filter option. Unfortunately the dynamic filter option doesn't work on date/time fields 😕

Returning this warning: https://community.servicenow.com/community?id=community_question&sys_id=980a56841babfc10aefc11751a4bcbf9

And the KB on this is missing: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0996113

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0749822

try this one!

Regards,
PaulSylo

Kindly mark "helpful", if this helps, or Mark as "Accepted " if it solves your issues !

Ah, cool find @Paul Sylo! I definitely bookmarked that one!  Whew, I got the function on filter condition to work before I saw this, so I'll probably stick with that way for now.

Calls two script include functions:

getHalfHourINC: function() {
var getTask, gdt, gt, gt1, timeFormatHH, timeFormatMM, timeFormatSS;
var arr = [];
getTask = new GlideRecord('incident');
getTask.addEncodedQuery("opened_atONLast 12 months@javascript:gs.beginningOfLast12Months()@javascript:gs.endOfLast12Months()^opened_atDATEPART5 pm hour@javascript:gs.datePart('hour','17','GE')^ORopened_atDATEPART6 pm hour@javascript:gs.datePart('hour','18','LE')");
getTask.query();
while (getTask.next()) {
gdt = new GlideDateTime(getTask.opened_at);
gt = gdt.getLocalTime();
timeFormatHH = gt.getByFormat('HH');
timeFormatMM = gt.getByFormat('mm');
timeFormatSS = gt.getByFormat('ss');
if ((timeFormatHH == 17 && timeFormatMM >= 30) || (timeFormatHH == 18 && timeFormatMM == 0)) {
arr.push(getTask.sys_id.toString());

}
}
return arr;
},
getHalfHourRITM: function() {
var getTask, gdt, gt, gt1, timeFormatHH, timeFormatMM, timeFormatSS;
var arr = [];
getTask = new GlideRecord('sc_req_item');
getTask.addEncodedQuery("opened_atONLast 12 months@javascript:gs.beginningOfLast12Months()@javascript:gs.endOfLast12Months()^opened_atDATEPART5 pm hour@javascript:gs.datePart('hour','17','GE')^ORopened_atDATEPART6 pm hour@javascript:gs.datePart('hour','18','LE')");
getTask.query();
while (getTask.next()) {
gdt = new GlideDateTime(getTask.opened_at);
gt = gdt.getLocalTime();
timeFormatHH = gt.getByFormat('HH');
timeFormatMM = gt.getByFormat('mm');
timeFormatSS = gt.getByFormat('ss');
if ((timeFormatHH == 17 && timeFormatMM >= 30) || (timeFormatHH == 18 && timeFormatMM == 0)) {
arr.push(getTask.sys_id.toString());

}
}
return arr;
},

Wow so cool!

Regards,
PaulSylo

Kindly mark "helpful", if this helps, or Mark as "Accepted " if it solves your issues !