Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Forward schedule of change query in ServiceNow

amitmanna
Giga Expert

Hello Friends

Can some one share the query for fetching the forward schedule of changes in ServiceNow 

1 REPLY 1

Me Being Mustaq
Tera Guru

Hi @amitmanna ,

 

You'll typically query the Change Request table (change_request) for changes that are scheduled in the future. Here's a sample query using GlideRecord in a script or a filter condition you can use in a report or module:

for changes that are scheduled in the future. Here's a sample query using GlideRecord in a script or a filter condition you can use in a report or module

var gr = new GlideRecord('change_request');
gr.addQuery('start_date', '>=', gs.nowDateTime()); // Only future changes
gr.addQuery('state', '!=', '3'); // Exclude 'Closed' changes
gr.orderBy('start_date'); // Sort by start date
gr.query();

while (gr.next()) {
gs.print('Change: ' + gr.number + ' | Start: ' + gr.start_date + ' | End: ' + gr.end_date);
}

 

You can use this in a list view or report:

Filter:- Start date is on or after Today AND State is not Closed

 

If it is helpful, please hit the thumbs-up button and accept the correct solution by referring to this solution in the future. It will be helpful to them.

 

Thanks & Regards,

Mohammed Mustaq Shaik