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

Community Alums
Not applicable

Try to use sysparm_view_forced = true in your argument such:

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

http://wiki.servicenow.com/index.php?title=View_Management#gsc.tab=0

 

Thanks,

Raf

That didn't work as expected. The redirect failed (which is after the the sysparm_view). If I comment it out, the redirect works

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);

Community Alums
Not applicable

Strange, it should work - can you please be careful with the naming convention & capital letters.

Account Request should be your label but the value should be account_request.

function createTask() {

//create the new Task record
var newTask = new GlideRecord("sc_request");
// set your fields here
var id = newTask.insert();
action.setRedirectURL('sc_request.do?sys_id=' + id + '&sysparm_view=account_request');

}

It was correct.  I just adjusted it to lower case, changed the redirect and attempted again. It created the record, but did not redirect me to it. I went back to the incident list

find_real_file.png