Create new Child incident from being on Parent

Pavithra36
Kilo Contributor

Hi All,

Please advise me on how to configure the option/button for creating New Child Incident from being on the Parent incident form. Once the Create New child is clicked, it should link to the existing parent on which we are currently in?

Can someone help me with the steps I need to follow in order to achieve this?   If anyone has done this, please share the script pattern for the same.

Awaiting your response.

1 ACCEPTED SOLUTION

1) If your requirement is to achieve it specifically via a UI button then have a UI Action with below code.


var inc = new GlideRecord("incident");


inc.initialize();


inc.short_description = 'Child Incident';


inc.parent = current.sys_id; //Relating the current incident as the parent


var sysID = inc.insert();



gs.addInfoMessage("Child Incident " + inc.number + " created");


action.setRedirectURL(inc);


action.setReturnURL(current);



2) You can also do this via the related list as Mrudula suggested. Personalize/Configure the list control and ensure the 'Omit new button' is unchecked.


find_real_file.png


find_real_file.png


View solution in original post

13 REPLIES 13

guhann
Mega Guru

Cretae a new UI Action on 'incident' table with below script.



var inc = new GlideRecord("incident");


inc.initialize();


inc.short_description = 'Child Incident';


inc.parent = current.sys_id; //Relating the current incident as the parent


var sysID = inc.insert();



gs.addInfoMessage("Child Incident " + inc.number + " created");


action.setRedirectURL(inc);


action.setReturnURL(current);


Hi Guhan,



Your code works for about 70 % but only thing which is not working here is, it creates a Child Incident and the number is displayed, but it does not get linked to the parent incident and get registered in the db. See below screen shot, which shows the behavior when Clicked on the UI action "Create Child Incident". After this I will have to go back to the parent. But parent remains as it is. Please check and let me know where I am going wrong.



Child Incident.jpg


1) If your requirement is to achieve it specifically via a UI button then have a UI Action with below code.


var inc = new GlideRecord("incident");


inc.initialize();


inc.short_description = 'Child Incident';


inc.parent = current.sys_id; //Relating the current incident as the parent


var sysID = inc.insert();



gs.addInfoMessage("Child Incident " + inc.number + " created");


action.setRedirectURL(inc);


action.setReturnURL(current);



2) You can also do this via the related list as Mrudula suggested. Personalize/Configure the list control and ensure the 'Omit new button' is unchecked.


find_real_file.png


find_real_file.png


Thank   you Guhan for your help and support. After Configuring the List control with Omit New Button unchecked, it worked



Thanks a TON!!