Client Script doesn't work on Agent Workspace - I have used getReference() with Callback function

gkbhandare003
Kilo Guru

Dear All,

I am trying to fill up some fields on Incident form using OnChange Client Script for field ' Affected CI'.

I have used a getReference()  with Callback function and this works on platform UI however doesn't work on Agent Workspace.

I have the isolate script 'unchecked' and UI type set to 'All'.

Script is as below:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
	var count = g_form.getValue('state');
	if (count!=1)
	g_form.setValue('assignment_group',"");
	
	vara ref = g_form.getReference('cmdb_ci',getData);
	
function getData(ref)
{
	var cat=g_form.getValue('category');

	if (cat=='Application'){
	var asset = ref.getValue('assignment_group');
	g_form.setValue('assignment_group', asset);
		
	}

	var support_team;
	var asset2 = g_form.ref.getValue('support_group');
	var grp=new GlideRecord('sys_user_group');
	grp.addQuery('sys_id',asset2);
	grp.query();
	if(grp.next())
		{
			support_team = grp.name;
		}
	
	g_form.setValue('u_support_team', support_team);
		
	var subcat=g_form.getValue('subcategory');
	if(!subcat){
	var asset1 = ref.getValue('ci_type');
	g_form.setValue('subcategory', asset1 );}
   }
	
}

Any suggestions on why this is not working as the other scripts which has used direct reference are working fine on agent workspace.

e.g 

g_form.setValue('u_personal_number', g_form.getReference('Caller').user_id;

 

Thanks

1 ACCEPTED SOLUTION

gkbhandare003
Kilo Guru

I was able to fix this by using separate callback function for each reference instead if combining all in one .. 

View solution in original post

1 REPLY 1

gkbhandare003
Kilo Guru

I was able to fix this by using separate callback function for each reference instead if combining all in one ..