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

I'm glad you got your question answered. Thank you for participating in the community.



If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.



If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View.



Thank you


Hi Chuk,

Can you please explain me the difference between:

1. g_scratchpad.assignment_group = grp.assignment_group

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

Is it a best practice to go with no. 2?

If yes then why?

 

Thanks!