How best to create recurring tickets for multiple people?

John Lockwood
Kilo Contributor

I want to setup an automatic recurring i.e. scheduled Incident which is assigned to System Owners and prompts them to do a maintenance task. Once they have completed the task they will be able to mark the incident as solved.

Note: I would not classify this as a recurring change request as the maintenance in question is to merely review who has access to their system.

I can see that I could create a template for an incident and set a schedule for it and this would therefore work for a single System Owner. However if I have say 20+ System Owners - other than duplicating this 20+ times is there a way of say creating one and choosing a group and it then creating individual recurring incidents for each member of the group?

On a related topic, would the System Owners need to be defined as 'fulfiller' level users so they can 'resolve' these tickets.

1 ACCEPTED SOLUTION

Ok below is the updated script.  You do not need to so variables for you table.  Once you query you have access to all the fields by doing source.u_short_description for example.  So you will see in my script below source.filed name.  When you see field name just replace it with the filed name in your source table.  Hope that makes sense.

var source = new GlideRecord('systemownerstable');
source.query(); // Issue the query to the database to get all records 
while (source.next()) {
//read fields of record
var target = new GlideRecord('incident');
target.initialize();
//set values in new incident
target.short_description = source.field name;
target.category = source.fieldname;
target.caller_id = source.fieldname;
target.assigned_to = sourcerec.fieldname;
target.description = source.fieldname;
// write new incident
target.insert();
}

View solution in original post

13 REPLIES 13

I'm note sure I'm following what you are saying but my idea was to use system definition > scheduled jobs.

Then write a script that quires you table then creates incidents base on the information in the table.  This will avoid using templates.

Sorry, I had seen prior to your answers mention of using templates to auto create records and still thought that would be involved. (Very new to ServiceNow, also not done JavaScript before.) Thank you for your help.

It seems that the following might be the right approach.

1. Create a new table listing systems and owners (done)

2. Create GlideRecord based script along the following lines

var source = new GlideRecord('systemownerstable');
var sourcerec_short;
var sourcerec_owner;
var sourcerec_description;

source.query(); // Issue the query to the database to get all records 
while (source.next()) {
//read fields of record
sourcerec_short = source.getValue('system');
sourcerec_owner = source.getValue('owner');
sourcerec_description = source.getValue('description');
var target = new GlideRecord('incident');

target.initialize();
//set values in new incident
target.short_description = sourcerec_short;
target.category = 'quarterlysystemaccessreview';
target.active = 'true';
target.caller_id = sourcerec_owner;
target.assigned_to = sourcerec.owner;
target.description = sourcerec_description;
// write new incident
target.insert();
}

3. Create schedule to run above GlideRecord script

 

I would expect I have made a huge number of errors in the above script. :-! So your corrections will be much appreciated.

Ok below is the updated script.  You do not need to so variables for you table.  Once you query you have access to all the fields by doing source.u_short_description for example.  So you will see in my script below source.filed name.  When you see field name just replace it with the filed name in your source table.  Hope that makes sense.

var source = new GlideRecord('systemownerstable');
source.query(); // Issue the query to the database to get all records 
while (source.next()) {
//read fields of record
var target = new GlideRecord('incident');
target.initialize();
//set values in new incident
target.short_description = source.field name;
target.category = source.fieldname;
target.caller_id = source.fieldname;
target.assigned_to = sourcerec.fieldname;
target.description = source.fieldname;
// write new incident
target.insert();
}

@bricast

Many thanks for your help, this script worked, using the limited demo data I added to my table it created matching records as incidents.

A related question if I may. The purpose of this is mentioned originally, to have a list of system owners and systems and to create automated incidents assigned to the owners who will then need to perform a task and once they have completed the task they can mark the incident as complete.

I can see that to do this they need to be Fulfiller level users. I can see using an Incident type record will do the job however it would be nice to be able to easily find these types of recurring 'work' separately to ordinary Helpdesk requests.

Other than creating an additional category and assigning these recurring tasks to this additional category do you have a view on whether creating a whole new table aka application for this would be better?

Yes you could create a scooped app that you could then crate you own role for these system owners to use.  This would not require license as fare as I know.