Child Incident Creation based on Affected CI (Please read question properly)

Sriram28
Tera Contributor

Hello Team,

 

Child incident should be created based on Affected CI when we click on "create child incident" option in "Action on selected Items" in that incident.

 

This is an urgent requirement.

 

If anyone already worked on it. Please let me know.

 

Thanks in advance.

7 REPLIES 7

Hi @Sriram28 

 

This is my weak area, I dont do coding. But if you check OOTB UI action code that can help.

 

@Sandeep Rajput  @AshishKM 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

@Sriram28 , create UI Action on incident form  and based on affecte ci [ task_ci] table, iterate the affected ci record create a new INC and add the main INC as parent. 

 

Sample code for UI Action already shared by @SnowReece 

 

You can make this process as backend via event + script action, on UI Action trigger the event and map the script action with event.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

SnowReece
Tera Expert

Something similar to the below will do what you ask. However, this could potentially create 100s of Incidents if you have many affected CIs.

var currentRec = current.sys_id;
var grTaskCi = new GlideRecord('task_ci');
grTaskCi.addEncodedQuery("task="+currentRec);
grTaskCi.query();
while(grTaskCi.next())
	{
		var createIncRec = new GlideRecord('incident');
		createIncRec.initialize();
		// Put your Incident stuff here.
		createIncRec.insert();
	}