The CreatorCon Call for Content is officially open! Get started here.

change view in form when opened from list ?

Kiddy
Tera Guru

Hi ,

 

i am looking to switch view from list 

ex: i have triage view on list view when i open a record i have to switch to custom view which 

i have created

 

find_real_file.png

 

when i open in form  it should change to australia view

find_real_file.png

1 ACCEPTED SOLUTION

Sajilal
Mega Sage

Hi Kiddy,

You can achieve this via below but please be warned do not use a Onload client script as the view will keep changing over and over again. So set a proper condition for OnChange and set your Client script up.

https://www.servicenowguru.com/scripting/client-scripts-scripting/change-form-view-client-script/  

function onChange(control, oldValue, newValue, isLoading) {
//If the page isn't loading
if(!isLoading){
//If the new value isn't blank
if(newValue != ''){
//Change to the 'ess' view if the Category is 'Hardware'
if(newValue == 'hardware'){
switchView('section','incident','ess');
}
}
}
}

Please Mark as ✅ Correct if this solves your issue and also mark ???? Helpful if it helps resolve your problem.

Thanks,
Saji

View solution in original post

2 REPLIES 2

Sajilal
Mega Sage

Hi Kiddy,

You can achieve this via below but please be warned do not use a Onload client script as the view will keep changing over and over again. So set a proper condition for OnChange and set your Client script up.

https://www.servicenowguru.com/scripting/client-scripts-scripting/change-form-view-client-script/  

function onChange(control, oldValue, newValue, isLoading) {
//If the page isn't loading
if(!isLoading){
//If the new value isn't blank
if(newValue != ''){
//Change to the 'ess' view if the Category is 'Hardware'
if(newValue == 'hardware'){
switchView('section','incident','ess');
}
}
}
}

Please Mark as ✅ Correct if this solves your issue and also mark ???? Helpful if it helps resolve your problem.

Thanks,
Saji

Willem
Giga Sage
Giga Sage

Try this:

It will change the view to australia when it was triangle.

if the view names are different from below, you can change triangle and australia to the correct name.

function onLoad() { 
  var view = getView();
  if (view == 'triangle') { 
    switchView('section', 'incident', 'australia');
  }
} 

 

If you always want to force a specific view it might be good to look at view rules:

https://docs.servicenow.com/bundle/orlando-platform-user-interface/page/administer/navigation-and-ui...