
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2017 01:12 AM
I have create new client script to switch view base on title field on sys_user table. But it seem switch infinite loop view list not specific view base on condition
How can I stop infinite load
below my script:
function onLoad() {
var employee = g_form.getReference('u_employee_name');
if(employee.title == 'Employee' || employee.title == 'Supervisor'){
switchView('section','u_incident_log','basic_view');
}
else if(employee.title == 'Manager') {
switchView('section','u_incident_log','Self_service');
}
else if(employee.title == 'Site Mgr' || employee.title == 'Vice President') {
switchView('section','u_incident_log','site_mgr_vp');
}
else{
switchView('section','u_incident_log','');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2017 09:04 PM
Hi Peter,
You can use onLoad client script for your requirement but should include some changes to avoid infinite loop. Please refer the below screenshot,
Just make sure the view names and case sensitivity are correct.
-Udhay
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2017 09:04 PM
Hi Peter,
You can use onLoad client script for your requirement but should include some changes to avoid infinite loop. Please refer the below screenshot,
Just make sure the view names and case sensitivity are correct.
-Udhay
Please Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2017 11:03 PM
Thanks for your involve. but It seem not resolve the problem.I still using onChange until find a way to fix onLoad.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2017 11:18 PM
Hi Peter,
I used my script in one of the developer instance and it worked without causing infinite loop. Please provide the XML of your onload client script, i'll try to resolve the issue .
-Udhay
Please Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2017 11:42 PM
It infinite surprised. Could you help me check what version are you working for? if as your Script to work I think it depend on Servicenow version
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2017 11:50 PM
I'm working on Jakarta version.
-Udhay