Script to create incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2016 11:02 AM
Hi Everyone,
We have a spreadsheet that had a list of servers in Column A, could you auto create a priority E ticket for every 10 servers in that spreadsheet??? For example, we have 800 servers that need to be queried for patch levels. We want to create 80 tickets where each ticket includes 10 servers. All tickets would have the same attributes…priority E, same assignment group, etc.
further, we would like to ink those 10 servers in the CI tab of the incident record.
Thanks,
Rahul kathuria
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2016 11:33 AM
Chuck, do you have a sample of this onstart transform script.?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2016 06:27 AM
Hi Chuck/Pradeep,
Can you please help here..i am trying to write an on start script to create incident and then on after script to calculate record count but it doesnot seem to work..
Thanks,
Rahul

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2016 06:36 AM
Hi Rahul,
The onStart script is pretty simple. (none of this is tested, but you should get the idea.)
var inc = new GlideRecord('incident');
inc.newRecord();
// Set other fields like state, short_description, etc. here
var incId = inc.insert();
Now incId is global and known to your other transform scripts.
onAfter looks something like this:
// Count how many CIs are attached to incId
// If there are 10, create a new one
var tc = new GlideAggregate('task_ci');
tc.addAggregate('COUNT');
tc.addQuery('task', incId);
tc.query();
if (tc.next()) {
var count = tc.getAggregate('COUNT');
if (count >= 10) {
// Create new incident
var inc = new GlideRecord('incident');
inc.newRecord();
// Other fields
incId = inc.insert();
}
}
// Attach this CI to the task
var newTc = new GlideRecord('task_ci');
newTc.newRecord();
newTc.task = incId;
newTc.ci_item = target.sys_id;
newTc.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2016 11:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2016 01:44 PM