'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

Hi, Just tried in PDI and its not working. Interaction State is not changing to "Closed Complete" though Incident gets created from interaction when UI action has been clicked. 

Hi,

please share complete scripts

workspace client script

other script as well

Regards
Ankur

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

Attached the script screenshot

Hi,

in workspace client script current won't work

this should work

function onClick(g_form) {
  g_form.setValue('state', 'closed_complete');
  g_form.save();
}

Regards
Ankur

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

Hey, Sorry. I was trying Current as well and sent you that screenshot. I have tried the above script as well but did't work. State still shows 'WIP'

Any other suggestions? thanks