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 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

current.insert() worked but my inc number did not enumerate. The () was the part I was missing from my initial attempt. Thank you for your reply.