create task or child incident for the current incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 05:44 AM
how we can create task or child incident when state changes on the incident form with whatever fields incident have
and when that task or child incident is closed then incident will get closed automatically with resolution code and resolution notes with minimum of 30 characters .
kindly help me out on completing this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 06:07 AM
Hi Devi,
To create an incident task or child incident, you need an after update business rule(s) that will fire when the state changes. In there, you simply declare an instance of either incident or incident task and start assigning values:
var theTask = new GlideRecord("incident_task");
theTask.setValue("parent", current.sys_id); //this associates the task with the incident
<other assignments to the task>
theTask.insert();
You need to be careful with automatically closing the incident when one child incident or task is closed unless you are absolutely certain that there will be no other tasks or child incidents. If you are sure, then you need another after update business rule(s) something like this:
var theParent = new GlideRecord("incident");
theIncident.get("sys_id", current.parent.toString());
theIncident.setValue("state", 7);
theIncident.setValue("close_code", <the code value>);
theincident.setValue("close_notes", <your message>);
theIncident.update();
The above should get you on the right track. I haven't tested the code so there are probbaly a few fat fingers somewhere in them.
:{)
Helpful and Correct tags are appreciated and help others to find information faster