- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2016 06:58 AM
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?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 10:51 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2016 07:16 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 08:51 AM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 10:48 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 10:51 AM
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