how to call g_scratchpad in client script?

Sharique Azim
Mega Sage

I want to populate a reference field based on the value i select on a field.

for that i have table : "ABC" from where i want to fetch data and put in the incident field.

The u_fcr field in a true false field ,category item being choicelist on both tables. Assignment group being reference field on both.

I have a BR and a CS for this

BR:

  var cat3= current.u_category_item;

  var grp = new GlideRecord('u_abc');

  grp.addEncodedQuery('u_category_item='+cat3.toString()+'^u_fcr_1=false');

  grp.query();

  if(grp.next()){

  g_scratchpad.assignment_group =grp.u_assignment_group;

  }

  var grp1=new GlideRecord('u_group_on_cti');

  grp1.addEncodedQuery('u_category_item='+cat3.toString()+'^u_fcr_1=true');

  grp1.query();

  if(grp1.next()){

  g_scratchpad.assignment_group1 =grp1.u_assignment_group;

  }

And on change client script:

if(g_form.getValue('u_fcr') == true){

var grp1=g_scratchpad.assignment_group;
g_form.setValue('assignment_group',grp1);

alert(g_form.getValue('assignment_group') +     grp1);

   

}

else
{
var grp2=g_scratchpad.assignment_group1;
g_form.setValue('assignment_group',grp2);

alert(g_form.getValue('assignment_group') +     grp2);

   

}

Why I am not able to set the assignment group?

1 ACCEPTED SOLUTION

im not sure didn't it   work in the first time.never mind i wrote on change script using client script gliderecord query and it worked absolutely fine


View solution in original post

6 REPLIES 6

Chuck Tomasi
Tera Patron

Two things quickly come to mind.



in your BR, change your



g_scratchpad.assignment_group = grp.assignment_group



to



g_scratchpad.assignment_group = grp.getValue('assignment_group');



Second, put some alert statements to validate you have a value to assign.



alert(g_scratchpad.assignment_group);


i guess the problem is with the CS, i am using a onchange script not onload.The g_scratchpad only queries when it loads and finds null everytime. isn't?


If you populate g_scratchpad with properties and objects in a display business rule, they are available to onChange client scripts as well as onLoad.


im not sure didn't it   work in the first time.never mind i wrote on change script using client script gliderecord query and it worked absolutely fine