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.

create a incidents automatically on a specific date

DavidPrice
Tera Contributor

I would like to create a schedule that create a incident on a specific date.

 

from example 

 

08/07/2025

15/07/2025

08/08/2025

etc

 

I have created a template to create the incident.

I can get it working on the week/day etc. 

 

but can not see a why that I can type my own date's in for it to run 

11 REPLIES 11

JessicaLanR
Kilo Guru
Kilo Guru

To create incidents on specific, custom dates like 08/07/2025, 15/07/2025, 08/08/2025, etc., using a schedule in ServiceNow, you’ll need to go beyond the standard Recurrence options in Scheduled Jobs or Scheduled Script Executions. These built-in tools don’t support arbitrary date inputs out-of-the-box. Here’s a practical approach to achieve it:

  1. Create a custom table (e.g., u_incident_schedule_dates) with a single Date/Time field to store all the desired incident creation dates.

  2. Populate this table with the dates you want incidents to be generated (08/07/2025, 15/07/2025, 08/08/2025, etc.).

  3. Create a Scheduled Script Execution (run daily, for example), that:

    • Queries the custom table for any records where the date equals today’s date.

    • For each match, uses the Incident Template to create an incident via GlideRecord or by calling GlideRecord.insert() with prefilled fields from your template.

Here is a basic example script for the Scheduled Script Execution:

var today = new GlideDate();
var incidentDateGR = new GlideRecord('u_incident_schedule_dates');
incidentDateGR.addQuery('u_date', today);
incidentDateGR.query();

while (incidentDateGR.next()) {
    var incident = new GlideRecord('incident');
    incident.initialize();

    // Apply values from your template
    incident.short_description = 'Scheduled Incident';
    incident.category = 'inquiry';
    incident.impact = 2;
    incident.urgency = 2;
    incident.insert();
}

Make sure to align field names and values according to your template. This way, you maintain a flexible list of custom dates that can be managed manually or via integration, and the automation will trigger based on those dates. If this resolves your issue, please consider marking the response as solved

Hi JessicaLanR
Thanks you for your help.

I have got it working in Dev now

 

Regards Dave