- 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-05-2018 03:20 PM
Hi Antonio,
Could you please share the script?
Thanks,
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2018 03:29 PM
Pradeep, thank you for your quick reply!
function onLoad() {
var viewName = getView();
var grView = new GlideRecord('sys_ui_view');
grView.addQuery('name','Default');
grView.query();
while(grView.next()){
if(grView.name == viewName){
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');}
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2018 04:18 AM
also i ma wondering what is the use case to include view name in the script here.
basically here in script you are checking for all views with name "Default" and again comparing same with form view.
if you want the change for only particular view then you can directly compare the view name with viewName variable in your code.
why extra GlideRecord?
Please let me know if i am missing something.
Thanks,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2018 04:27 AM