We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

switch the view using UI action

omsa1
Kilo Guru

Hi There,

I created a new view "GS" in incident table. I need to create a UI action to switch to default view.

i tried with all these and none of them working. it just redirecting to incident list view. How can i switch the view from GS to default and display same incident record? 

function SwitchToDefault() { 

var id = current.sys_id;

g_form.checkMandatory = false;


//action.setRedirectURL('incident.do?sys_id=" + id + "&sysparm_view=default');
// action.setRedirectURL('incident.do?sys_id=' +id + '&sysparm_view=default');
//action.setRedirectURL("nav_to.do?uri=incident.do?sys_id=" + current.sys_id.toString());
//action.setRedirectURL('https://<instance name>.service-now.com/nav_to.do?uri=incident.do?sys_id=e5ad731bdb83b380cd8190b3db9619ee');
action.setRedirectURL('https://<instance name>.service-now.com/nav_to.do?uri=incident.do?sys_id=e5ad731bdb83b380cd8190b3db9619ee');

}

 

 

1 ACCEPTED SOLUTION

Hi Omkar, 

 

I can't switch back to default view while in GS view because of view rule not allowing this. Therefore, i hide and unhide the field using script instead creating new view.

View solution in original post

7 REPLIES 7

SanjivMeher
Mega Patron

You can use a UI action with below script. Uncheck the client checkbox in UI action if you have it checked.

 

action.setRedirectURL("incident.do?sys_id=" + current.sys_id + "&sysparm_view=default&sysparm_view_forced=true");


Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv,

 

Thanks for quick reply, i tried this and it is not working ,  redirecting to incident list view as well. 

Can you post your recent code?

Hi Omkar, 

 

I can't switch back to default view while in GS view because of view rule not allowing this. Therefore, i hide and unhide the field using script instead creating new view.