How to create incident from a business rule?

sheths
Kilo Explorer

Hi All,

I am trying to create an incident if CI is not found on a particulate table. Below is the business rule code that looks for CI's.

When: before

Insert: Checked

var circuit = new GlideRecord('cmdb_ci_ip_network');

circuit.addQuery('u_circuit_reference',current.u_circuit_string);

circuit.query();

if (circuit.next()){

current.u_ci = circuit.sys_id;

current.u_status = "Found CI circuit match";

}

else {

current.u_status = "No CI circuit match";

current.u_notify = false;

}

I would appreciate any help or starting point on what I need to add to create an incident if the CI circuit match is not found.

Thank you.

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Shoaib,



This is sample script and you can modify it according to your conditons.


var gr = new GlideRecord('incident');


gr.initialize();


gr.short_description = 'learn about GlideRecord';


gr.insert(); //insert the new record


Please refer below wiki link section12 for more info


http://wiki.servicenow.com/index.php?title=GlideRecord



Thanks


Pradeep Sharma


View solution in original post

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Shoaib,



This is sample script and you can modify it according to your conditons.


var gr = new GlideRecord('incident');


gr.initialize();


gr.short_description = 'learn about GlideRecord';


gr.insert(); //insert the new record


Please refer below wiki link section12 for more info


http://wiki.servicenow.com/index.php?title=GlideRecord



Thanks


Pradeep Sharma


Thank you for your Help Pradeep.


I am glad I can be helpful


Would you mind marking my answer as correct if is resolved.



Thanks


Pradeep


i m okey with code


but i want


Create a Problem from Incident ticket.Once the problem ticket is closed corresponding incident ticket should also get resolved.