Setting a UI View using a UI Action

scottangehr
Giga Guru

Good day team

I'm having a conundrum with setting a view using a UI Action.  It worked previously and doesn't seem to want to now.  I have used the following to set the view when a UI Action is clicked:

   var link ="sc_request.do?sys_id="+sysID+"&sysparm_view=Account_Request";

When that didn't work, I searched the community and attempted to use this:

   task.set('sysparm_view', 'Account_Request');
   task.set('sysparm_view_forced','true');

Any help is appreciated.

Regards,
Scott

1 ACCEPTED SOLUTION

scottangehr
Giga Guru

Moved this up to after the tasksys.insert and it works

var link ="sc_request.do?sys_id="+task.sys_id+"&sysparm_view=account_request";
action.setRedirectURL(link);

View solution in original post

17 REPLIES 17

Its client side

Here is my code

var task = new GlideRecord("sc_request");

//removed all other code

var link ="sc_request.do?sys_id="+sysID+"&sysparm_view=Account_Request"+"sysparm_view_forced=true&sysparm_userpref_module=false"; 

   gs.addInfoMessage(gs.getMessage("Request {0} created", task.number));
   action.setRedirectURL(task);
   action.setReturnURL(current);

Hi,

in client side code you cannot use action object

you can use below

what is the sysID variable storing and how value is stored in it?

var link ="/sc_request.do?sys_id=" + sysID + "&sysparm_view=Account_Request" + "sysparm_view_forced=true&sysparm_userpref_module=false"; 

window.open(link);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Then maybe its server side? I copied an OOB action.

Let me try this

No - that did not work.

When I do not have the set view in the code, the redirect works as expected.
As soon as I add to set the view, that's where the code stops

Hi,

If you add sysparm_view parameter it fails?

Did you check any view rule on that table?

Regards

Ankur

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