Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Create multiple incidents from single record producer?

wbmore
Kilo Expert

Good morning All,
I have a request to create a daily check list for the infrastucture team to track proactive efforts. I built a straight forward record producers that mearly requires a click of the submit button if all is well. If errors, warning, or investigation check boxes are selected I would like to create an incident per variable captureing the associated text variables. Most of this process is straight forward in my mind with a simple set of if statements. I tried using current.insert; but it did not generate multiple incidents.

Very simple stages at this point.
if (producer.citrix_warning == "true")
{
current.short_description = "Citrix Warning";
current.assignment_group.setDisplayValue("Infrastructure");
current.assigned_to = producer.caller_id;
current.insert;

}

if (producer.vmware_warning == "true")
{
current.short_description = "vmware Warning";
current.assignment_group.setDisplayValue("Infrastructure");
current.assigned_to = producer.caller_id;
current.insert;
}

Thanks
Bruce

1 ACCEPTED SOLUTION

Aaron40
Kilo Guru

Hi.

I've never done this personally but you should be able to do this by manually creating a new GlideRecord insert. Reusing "current" won't create unique records but if you go through a GlideRecord query and insert that way, you should get the second unique record created.

Something like...



var gr = new GlideRecord('incident');
gr.initialize();
// you'll need to go through all of the variables on your record
gr.short_description = g_form.getValue('short_descrpition'); // like this
gr.insert();


See more at http://wiki.servicenow.com/index.php?title=GlideRecord#Insert_Methods


View solution in original post

5 REPLIES 5

Aaron40
Kilo Guru

Hi.

I've never done this personally but you should be able to do this by manually creating a new GlideRecord insert. Reusing "current" won't create unique records but if you go through a GlideRecord query and insert that way, you should get the second unique record created.

Something like...



var gr = new GlideRecord('incident');
gr.initialize();
// you'll need to go through all of the variables on your record
gr.short_description = g_form.getValue('short_descrpition'); // like this
gr.insert();


See more at http://wiki.servicenow.com/index.php?title=GlideRecord#Insert_Methods


This worked perfectly. Thanks for your response.


You're welcome!

Glad it worked!


adiddigi
Tera Guru

What you forgot is using


current.insert()
in the place of

current.insert
. If your record producer is configured over Incident table, you don't need to initialize another Glide.

Also,

current.insert
will not CALL the function

insert
for you, though it does gives your a reference (just like a pointer in C or C++) to that function, So you have to use

current.insert()
.