Resolve Child Incidents from a Parent Incident using UI Action button.

Bijay Kumar Sha
Giga Guru

I've a requirement where, 

On incident form, if the logged in user is part of Application support group, user should be able to view the Button “Resolve child tickets”. On click of this button, user should receive a confirmation message. “There are X child incidents associated with this ticket” Do you want to resolve these child tickets ?.

If user selects Yes, then the associated child tickets should be resolved with the resolution codes of parent incident.

If user selects No, then no action is needed.

 

However I was trying to implement. But it is not working. Find my below code in UI Action page:

function resolveChildIncident()
{
//var count = g_form.get('child_incidents');
var answer=confirm("There are X child incidents associated with this ticket. Do you want to resolve these child tickets?");
if (answer == true)
{
gsftSubmit(null,g_form.getFormElement(),'sys_resolvechildincident');
}
}


var gr=new GlideRecord('incident');
gr.addQuery('parent_incident',current.sys_id);
gr.query();
while(gr.next())
{
gr.state='6';
gr.update();
}
action.setRedirectURL(current);

 

//

 

In this UI Action page below are the field name-

UI Action Name: Resolve Child Incident

Action Name: sys_resolvechildincident

Onclick: resolveChildIncident();

 

Let me know if anyone can help me out on this.

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

Try below script:

function resolveChildIncident()
{
//var count = g_form.get('child_incidents');
var answer=confirm("There are X child incidents associated with this ticket. Do you want to resolve these child tickets?");
if (answer == true)
{
gsftSubmit(null,g_form.getFormElement(),'sys_resolvechildincident');
}

 

if (typeof window == 'undefined')
serveResolve();

function serveResolve(){
var gr=new GlideRecord('incident');
gr.addQuery('parent_incident',current.sys_id);
gr.query();
while(gr.next())
{
gr.state='6';
gr.update();
}
action.setRedirectURL(current);

}

 

Thanks,
Ashutosh Munot 

View solution in original post

4 REPLIES 4

Kunal Varkhede
Tera Guru

Hi,

 

If you want to hide/show this Ui Action based on Condition then try below script

gs.getUser().isMemberOf('Application support')

 

In Your code add this

if(typeof window == 'undefined')
   runBusRuleCode();

 

I have edited your code.

Try below code

function resolveChildIncident()
{
//var count = g_form.get('child_incidents');
var answer=confirm("There are X child incidents associated with this ticket. Do you want to resolve these child tickets?");
if (answer == true)
{
gsftSubmit(null,g_form.getFormElement(),'sys_resolvechildincident');
}
}

if(typeof window == 'undefined')
   runBusRuleCode();

function runBusRuleCode()
{
//Server-side function

var gr=new GlideRecord('incident');
gr.addQuery('parent_incident',current.sys_id);
gr.query();
while(gr.next())
{
gr.state='6';
gr.update();
}
action.setRedirectURL(current);
}

 

Please Mark Correct/Helpful answer if it help you in any way.

Thanks,

Kunal

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

Try below script:

function resolveChildIncident()
{
//var count = g_form.get('child_incidents');
var answer=confirm("There are X child incidents associated with this ticket. Do you want to resolve these child tickets?");
if (answer == true)
{
gsftSubmit(null,g_form.getFormElement(),'sys_resolvechildincident');
}

 

if (typeof window == 'undefined')
serveResolve();

function serveResolve(){
var gr=new GlideRecord('incident');
gr.addQuery('parent_incident',current.sys_id);
gr.query();
while(gr.next())
{
gr.state='6';
gr.update();
}
action.setRedirectURL(current);

}

 

Thanks,
Ashutosh Munot 

Thank you Ashutosh. Yes, it worked. May I know how it worked by introducing 

if (typeof window == 'undefined')
serveResolve();