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

This comment is for people that may encounter this in the future:

Create a new UI Action for the record.
Condition: RP.getParameterValue('sysparm_view') == 'View_Name'
Script: 

action.setRedirectURL("incident.do?sysparm_view=&sysparm_stack=&sys_id=" + current.sys_id + "&sysparm_userpref.sc_req_item.view=&sysparm_userpref.sc_req_item_list.view=");

I put a Check mark in "Form button" so when in a specific view, a button shows in the top, if you click this button, you are taken back to the default view.

 

Dhananjay Pawar
Kilo Sage

Hi,

Check below link, it may help you,

https://community.servicenow.com/community?id=community_question&sys_id=ab301fe5dbdcdbc01dcaf3231f9619df&view_source=searchResult

Mark correct/helpful based on impact.

Thanks,

Dhananjay.

DrewW
Mega Sage
Mega Sage

Have you verified that there are no view rules that are competing with what you are doing?  View Rules can be set to override what is supplied via URL.