- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2020 09:25 PM
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
when i open in form it should change to australia view
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2020 09:57 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2020 09:57 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2020 10:07 PM
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: