- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 03:14 PM
Team,
I created an onload client script to set category, assignment group and other fields to speed up the fill out of form, you guys know time is money 🙂
Everything works nice when I create a new incident since my userID is associated with admin role, but when any user out of admin role goes to new incident, the onload client script does not work, that user has ITIL role, ok? Have you already seem this before? Appreciate any help!
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2018 04:38 AM
Then in that case you can directly have view name to compare in the script. try below script
function onLoad() {
var viewName = getView();
if(grView.name == "default"){ //here you know for which view the script should work. so you can directly compare view name. if it should apply for multiple views, you can have or (||) condition in if().
g_form.removeOption('u_qs_type','Alert');
g_form.removeOption('u_qs_type','Incident');
if (g_form.getValue('category')=='' || g_form.isNewRecord() == 'false'){
g_form.setValue('category', '1');}
if (g_form.getValue('assignment_group')=='' || g_form.isNewRecord() == 'false'){
g_form.setValue('assignment_group', 'ab08f792db946b006769980c8a961455');}
}
}
}
let me now for any query.
Thanks,
Ali
Thank you,
Ali

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2018 04:38 AM
Then in that case you can directly have view name to compare in the script. try below script
function onLoad() {
var viewName = getView();
if(grView.name == "default"){ //here you know for which view the script should work. so you can directly compare view name. if it should apply for multiple views, you can have or (||) condition in if().
g_form.removeOption('u_qs_type','Alert');
g_form.removeOption('u_qs_type','Incident');
if (g_form.getValue('category')=='' || g_form.isNewRecord() == 'false'){
g_form.setValue('category', '1');}
if (g_form.getValue('assignment_group')=='' || g_form.isNewRecord() == 'false'){
g_form.setValue('assignment_group', 'ab08f792db946b006769980c8a961455');}
}
}
}
let me now for any query.
Thanks,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2018 07:45 AM
Ali, you are right! I just removed the GlideRecord and compared the view directly, it worked to admin and non-admin role! thank you so much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2018 03:43 AM
Any idea what's happening?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2018 03:53 AM
Hello,
GlideRecord should not be used in client scripts.
Use GlideAjax instead.
https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/reference/r_ExamplesOfAsynchronousGlideAjax.html
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2018 04:29 AM