action.setRedirectURL() not working in customer service scope on agent workspace

Dubz
Mega Sage

Hi All,

 

OK, so i have a UI action that creates a task and redirects to that task once it has been created. It's all server side code, nothing complex.

I have this UI action on the incident form and it works on the normal view and in the agent workspace as required; it creates an incident task and redirects to that form.

I have the same UI action on the case form (insert and stay, realigned to the correct table and amended the glide record to open a case task). This works in the normal view but doesn't redirect to the new task form in the agent workspace.

I can't for the life of me figure out why not. There's nothing documented on conditions for this API to work, i've tried adding in related lists and messing with the forms to ensure case is set up the same as incident but to no avail.

The UI action is below, the code if fine, as i say it works on incident when creating an incident task but just doesn't work on case.

var csTask = new GlideRecord("sn_customerservice_task");
csTask.initialize();
csTask.service_offering = current.service_offering;
csTask.short_description = current.short_description;
csTask.company = current.company;
csTask.parent = current.sys_id;
csTask.priority = current.priority;
csTask.u_opco = current.u_opco;
csTask.insert();


gs.addInfoMessage("Task " + csTask.number + " created");
action.setRedirectURL(csTask);
action.setReturnURL(current);

Any ideas welcome.

1 ACCEPTED SOLUTION

This issue is quite familiar to me. 

can you try to use below line instead of action.setRedirectURL()

 

action.openGlideRecord(csTask);

 

eg:

 

var csTask = new GlideRecord("sn_customerservice_task");
csTask.initialize();
csTask.service_offering = current.service_offering;
csTask.short_description = current.short_description;
csTask.company = current.company;
csTask.parent = current.sys_id;
csTask.priority = current.priority;
csTask.u_opco = current.u_opco;
csTask.insert();


gs.addInfoMessage("Task " + csTask.number + " created");
action.openGlideRecord(csTask);
action.setReturnURL(current);

 

 

or if you want to use action.setRedirectURL() then build your ui action in global scope. 

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Did you check any browser console error?

refer below links

Agent Workspace Redirect URL Using UI Action not working

UI action redirect to a new window/tab using server-side script

Regards
Ankur

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

Yeah i've read both of those links, neither of any help 😞

Console is giving and unhandled redirect type:

chrome.jsdbx?sysparm_substitute=false&uxpcb=1606211982595:formatted:102858 Unhandled redirect type {type: "NOT_FOUND", url: "sn_customerservice_task"}

Have you any idea where that type is set?

Hi,

I could see action.setRedirectURL() in UI action for workspace

possibly setReturnURL is causing the issue; try commenting that once

refer this link

UI Action 'Confirm()' on Agent Workspace

Regards
Ankur

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

I have the exact same UI action working on the incident form in agent workspace with no issues, it redirects and returns just fine. Nonetheless, i tried commenting that line out but it made no difference.