UI Action on Workspace

Alex Saager1
Tera Contributor

Hi Community,

I have the below script that is used in the platform view to convert incidents to requests, my question is there an easy way for this to be added in SOW, ideally I'd like for it to be available in platform view AND SOW?

 

I thought it would be as easy as copying the script from the script field to the Workspace Client Script field but that didn't seem to work:

 

AlexSaager1_2-1726651356329.png

 

 

Many thanks,

Alex

 

var increq = new GlideRecord('sc_request');

increq.short_description = "Request converted from " + current.number;
increq.requested_for = current.caller_id; // caller copied

var sysID1 = increq.insert();
current.sc_request = sysID;

//////////////////////////////////////////

var incritem = new GlideRecord("sc_req_item");

incritem.request = increq.sys_id;
incritem.short_description = current.short_description + " converted from " + current.number;
incritem.cmdb_ci = current.cmdb_ci;
incritem.stage = "Delivery";
incritem.state = "Work in Progress";
incritem.priority = current.priority;

var sysID2 = incritem.insert();
current.sc_req_item = sysID;

////////////////////////////////////////////////

var inctask = new GlideRecord("sc_task");

inctask.short_description = current.short_description;
inctask.description = current.description;
inctask.cmdb_ci = current.cmdb_ci;
inctask.sys_domain = current.sys_domain;
inctask.assignment_group = current.assignment_group;
inctask.assigned_to = current.assigned_to;
inctask.work_notes = current.work_notes.getJournalEntry(-1); // work notes copied
inctask.comments = current.comments.getJournalEntry(-1); //comments copied
inctask.created_by = current.caller_id.user_name;
inctask.u_converted = true;
inctask.work_notes = "Ticket was originally raised on: " + current.opened_at + ". Ticket converted from " + current.number;
inctask.request_item = incritem.sys_id;
inctask.u_original_incident_number = current.number;

var sysID = inctask.insert();
GlideSysAttachment.copy('incident', current.sys_id, 'sc_task', sysID); // Attachment copied form INC to inctask

//////////////////////////////////////////
// Close Incident with Resolution Notes //
//////////////////////////////////////////
//current.work_notes = "Incident converted to request.";
//current.state = 7; // Set state to Resolved. You may need to adjust the state value based on your instance's configuration.
current.u_conversion = "1";
current.update();

//////////////////////////////////////////

current.sc_task = sysID;

gs.addInfoMessage("Catalog task " + inctask.number + " created");

action.setRedirectURL(inctask);
1 ACCEPTED SOLUTION

Aniket15
ServiceNow Employee
ServiceNow Employee

hello @Alex Saager1 

 

Please try to set the checkbox "Format for configurable workspace" and then save the ui action this should ideally work for you.

 

Thanks

Aniket

 

P.S Please mark the answer as helpful/correct if this helps to solve the problem.

View solution in original post

1 REPLY 1

Aniket15
ServiceNow Employee
ServiceNow Employee

hello @Alex Saager1 

 

Please try to set the checkbox "Format for configurable workspace" and then save the ui action this should ideally work for you.

 

Thanks

Aniket

 

P.S Please mark the answer as helpful/correct if this helps to solve the problem.