- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 03:15 AM
Hi All,
I have a requirement to create a parent incident on the basis of child incidents selected in the incident table by clicking a button in the banner with many to one relation(i.e. for multiple incidents selected one parent incident to be created). For one to one it is working with this in UI action -
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = 'parent';
var id = gr.insert();
current.parent_incident =id;
current.update();
but I am not able to create for multiple. How can this be achieved??
Thanks in advance!!
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 11:46 PM
Hello Aritra,
Happy to know that my solution has helped you. I have updated a few more things like a confirmation popup, & an alert if records are selected.
Please go through the below article.
UI ACTION to create a parent incident on the basis of selected records[act as child incidents] from ...
Mark it as helpful & correct, If Applicable
Cheers..!
Happy Learning:)
Tushar
Cheers..!

Happy Learning:)

Tushar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 08:50 AM
Hello Aritra Gupta,
I have tried the same use-case on my personal PDI and it works fine.
Let's start.....!
We will be creating UI Action & Script include.
UI Action
Copy & paste the below script in the section
function OnClick() {
var id;
var sysid_array = [];
sysid_array = g_list.getChecked();
var ga = new GlideAjax('InstanceMapper');
ga.addParam('sysparm_name', 'create');
ga.addParam('sysparm_ids', sysid_array);
ga.getXML(answer);
function answer(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert("The new Incident is created with "+answer);
}
}
Script Include
SI - Code
var InstanceMapper = Class.create();
InstanceMapper.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
create: function() {
var id;
var ids = this.getParameter('sysparm_ids');
var id_array = ids.split(',');
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = 'parent is almost done';
id = gr.insert();
for (var i = 0; i < id_array.length; i++) {
var inc = new GlideRecord("incident");
inc.get(id_array[i].toString());
inc.parent_incident = id;
inc.update();
}
return gr.number;
},
type: 'InstanceMapper'
});
OUTPUT:
Once you will select the tickets from the list & click on the create parent. An alert will popup with the new incident number & under that you will be able to see the children(which one we have selected).
Let me know, if you are facing any issues. If my answer helps you please mark it as correct & helpful
Cheers..!
Happy Learning
Tushar
Cheers..!

Happy Learning:)

Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 11:33 PM
Hi Tushar,
Thank you for your help it is working.
Regards,
Aritra

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 11:46 PM
Hello Aritra,
Happy to know that my solution has helped you. I have updated a few more things like a confirmation popup, & an alert if records are selected.
Please go through the below article.
UI ACTION to create a parent incident on the basis of selected records[act as child incidents] from ...
Mark it as helpful & correct, If Applicable
Cheers..!
Happy Learning:)
Tushar
Cheers..!

Happy Learning:)

Tushar