- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
08-09-2018 08:29 PM
Hi, I have a requirement, after select an assignment group, one of the members from the group should auto populate. If the assignment group field clear again, the assigned to field will be cleared also. I am new to ServiceNow, and any help is appreciate, thanks!
function onChange(control, oldValue, newValue, isLoading, isTemplate) {   
         if (isLoading || newValue === '') {
                   return;
         } 
         
         var gr = new GlideRecord('sys_user_grmember');
    
  gr.addQuery('group', g_form.getValue('assignment_group'));
         gr.query(function(_gr) {
                   if (_gr.next()) {
                          
        g_form.setValue('assignment_group', _gr.group.toString());
                   }
         });
}
Solved! Go to Solution.
- Labels:
 - 
						
							
		
			Incident Management
 
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
08-12-2018 08:23 PM
you may try like,
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
 if (isLoading) {
 return;
 }
if (newValue != ''){
 var gr = new GlideRecord('sys_user_grmember');
 gr.addQuery('group', newValue);
 gr.query();
 if (gr.next())
 g_form.setValue('assigned_to', gr.user);
 }else if (newValue == '') {
 g_form.clearValue('assigned_to');
 }
}
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
08-12-2018 08:47 PM
This works perfect, thank you Shishir!
