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 Incident from an Event

MStritt
Tera Guru

Is it possible to create an Incident, when a specific Event occurs? If Event 'integration.send_warning' triggers, create an Incident. And add the following values to the Incident:

 

Description = Parm 1 of the Event

Short description = Download Activity Alert

Assigned Group = Download Activity Alert 

1 ACCEPTED SOLUTION

Hi @MStritt,

 

There is no need to create a Script Include for this, you can add the script in the Script Action.

Try the following script:

var incGr = new GlideRecord('incident');
incGr.initialize(); 
incGr.setValue('description', event.parm1.toString());
incGr.setValue('short_description', 'Download Activity Alert'); 
incGr.setDisplayValue('assignment_group', 'Download Activity Alert'); 
incGr.insert();

Note that you are using the display value of the assignment group. This may change in the future, so you may want to consider using the sys_id instead.

 

View solution in original post

13 REPLIES 13

Manisha Reddy K
Mega Guru

Hi @MStritt ,

     Create an after insert BR on 'sysevent' table with the condition as 'event name = integration.send_warning' and write the script in the Advanced section to create an incident Record in the Incident Table and Map the respective values.

Thanks Manisha.

 

Can you provide sample code/script I can use?

Here's what I configured for the BR on the sysevent table. When the event fired, an Incident wasn't created.

 

Download Activity BR_1.png

 

Download Activity BR_2.png

 

var gr = new GlideRecord('incident');
gr.initialize(); 
gr.description = current.parm1;
gr.short_description = 'Download Activity Alert'; 
gr.assignment_group = 'Download Activity Alert';  
gr.insert();

James Chun
Kilo Patron