Javascript query in Platform Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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:gs.dateGenerate(gs.daysAgo(-0).substring(0,10),'18:00:00')^start_date<=javascript: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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'
};
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader