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

Hi,

Have you given the Action Name to this UI Action.  If not, provide a name in it.

 

Thanks,

Narsing

There's no client-side code in here so there's no need for an action name, i've tested with one anyway but it makes no difference.

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. 

That worked a treat Harsh, thanks a lot. It would be helpful if the API docs didn't list setRedirectURL as a viable option for scoped dev!

EDIT: actually still quite confused by this, the UI action worked fine in normal view (non-agent workspace) so scope can't have been the issue. Must be something to do with agent workspace itself.