'Create Incident' UI action in Interaction form (Agent Workspace UI)

Vinay52
Tera Expert

Hi, When Incident ticket gets created from the Interaction record with "Create Incident" UI action or associate existing record using "Associate Record" UI action - Would want to update the "state" of Interaction to "Closed Complete" 

OOB script is:

if(current.update()){
var inc = new GlideRecord("incident");
inc.initialize();
inc.caller_id = current.opened_for;
inc.short_description = current.short_description;
action.openGlideRecord(inc);
}

Should this be done by using any of this? current.state="closed_complete" or g_form.setValue(state,"closed_complete") 

I tried both but it did't work. 

I have also added Interaction field in Incident form layout under related record section. How do I update the "related record" in Incident form to update the Interaction number once it gets created from Interaction record. Thanks 

 

1 ACCEPTED SOLUTION

Hi,

this worked well for me

In Server Side Script

if(current.update()){
    var inc = new GlideRecord("incident");
    inc.initialize();
    inc.caller_id = current.opened_for;
    inc.short_description = current.short_description;
    
    current.setValue('state', 'closed_complete');
    current.update();
    
    action.openGlideRecord(inc);
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please share your complete script

the below code is server side so you will have to use current object and set the values

if(current.update()){
var inc = new GlideRecord("incident");
inc.initialize();
inc.caller_id = current.opened_for;
inc.short_description = current.short_description;
action.openGlideRecord(inc);
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hey,

On Workspace Client Script

function onClick(g_form) {

g_form.setValue('state', 'closed_complete');
g_form.save();

}

Hi,

this should work

Any issue faced?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi, No, its not working. When Create Incident UI action clicked, it creates incident but Interaction state still shows "Work in Progress". Attached the screenshot. any thoughts on where is the issue? thanks