- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 01:55 AM
Hi guys,
I need to autopopulate the assignment group field on form load, I have wrtiten the below client script code.
I am able to populate the group field, But going down the road If we upgrade the instance to higher version does it cause any effect...Please correct me I am going in the right way or not???
function onLoad() {
//Type appropriate comment here, and begin script below
var x = 'eecdfd9bff131100a0a5ffffffffffe9'; // sys_id of the group name
g_form.setValue('assignment_group',x);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 03:19 AM
Hi Naveen,,
Although I am against the use of gliderecords on client script as earlier mentioned, indirectly you are hardcoding scripts which is even less reliable. But nevertheless in the code,please modify to
function onLoad() {
if(g_form.isNewRecord()){
//Type appropriate comment here, and begin script below
var gr = new GlideRecord('sys_user_group');
gr.addQuery('name',"Facilities request assignment group"); //as per my experience group name changes later during the time.
gr.query();
if(gr.next()){
g_form.setValue('assignment_group',gr.sys_id);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:20 AM
just try to use dictionary override if you will implement this then it will only work on the current table.
Dictionary Overrides - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 01:59 AM
Please check the link below.
https://www.servicenowguru.com/system-definition/assignment-rule-lookup/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:00 AM
Hello Naveen,
Yup definitely, it will cause an issue if you are upgrading the instance as your playing with sys id here. I would suggest you to use below script to get sys id of a group depending on the name.
var gr = new GlideRecord('sys_user_group');
gr.addQuery('name',"Group name here");
gr.query();
if(gr.next()){
g_form.setValue('assignment_group',gr.sys_id;)
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:03 AM
Hi
i would recommend try to avoid glide record in client script. Performance is the main key factor. it it's slow then it's really make sad to the user who use that application;
try to use glide ajax if you want to do glide record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:11 AM
Hi harsh,
Do u have any sample code for this, I am confused with all the codes avaliable here??