Javascript query in Platform Analytics

Karine_M
Tera Guru

Hi,

I would like to know how to retrieve filtered information from calculated data using JavaScript in Platform Analytics. For example, I need to retrieve all scheduled changes between 6 PM tonight and 8 AM in two days into a report.

 

In Change List I use this query :

stateIN-2,-1^start_dateISNOTEMPTY^start_date>=javascript&colon;gs.dateGenerate(gs.daysAgo(-0).substring(0,10),'18:00:00')^start_date<=javascript&colon;gs.dateGenerate(gs.daysAgo(-3).substring(0,10),'08:00:00')

 

and I would like to integrate this query into my dashboard. It is possible ? If so, how ?

 

Karine

 

3 REPLIES 3

Tanushree Maiti
Tera Patron

Hi @Karine_M 

 

Refer: KB0746219 Creating dynamic JavaScript filters in reports 

https://www.servicenow.com/community/platform-analytics-forum/date-calculation-on-report/m-p/1228156

 

Sample script Include :

var GetScheduledChangeWindow = Class.create();
GetScheduledChangeWindow.prototype = {
initialize: function () { },

getChangeWindow: function () {
var startDateTime = new GlideDateTime();
startDateTime.setDisplayValue(gs.nowDate() + " 18:00:00");
var endDateTime = new GlideDateTime();
endDateTime.setDisplayValue(gs.nowDate() + " 08:00:00");
endDateTime.addDays(2);
return "start_dateBETWEEN" + startDateTime.getValue() + "@" + endDateTime.getValue();
},
type: 'GetScheduledChangeWindow'
};

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Karine_M
Tera Guru

Thank you for your feedback, but I want to retrieve this information from Platform Analytics, not from Reports.

Is it also possible to call a script directly from a Platform Analytics visualization/data source?

 

Karine

Ankur Bawiskar
Tera Patron

@Karine_M 

I think if you use technical editor for platform analytics then it might be possible

check this

Technical Dashboards & Workspace Insights - January 7th, 2026 - Platform Analytics Academy 

Create a technical dashboard in UI Builder 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader