- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 02:25 AM - edited 04-26-2023 02:25 AM
We have created and custom field on incident form called service which refers to a custom table which has entries for category,subcat1, subcat2 and assignment group all they fields are of string type in the table.
we have creates an on change client script
var test123 = g_form.getReference('u_service');
g_form.setValue('category', test123.u_category);
g_form.setValue('subcategory', test123.u_subcategory_1);
g_form.setValue('u_subcategory', test123.u_subcategory_2);
g_form.setValue('u_subcategory', test123.u_subcategory_2);
which sets the value to all the fields , also assignment group gets group name field in ,but has when we try to preview the assignment group it shows no record found also not able to save the form and it gives error : Match not found, reset to original under the assignment group
it will be really helpful if there is any feedback on the same
regards
Karan V
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 04:08 AM - edited 04-26-2023 04:16 AM
Technically there shouldn't be a problem.
It's recommended to use a callback function with getReference, but that's not breaking it even if you don't.
In your example you're not setting the assignment group so it's hard to say what's wrong.
I did a test (similar to your script) for cmdb_ci field on incident form. When the value is changed it should take the support group and populate it as the assignment group on the incident form.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var test123 = g_form.getReference('cmdb_ci');
g_form.setValue('assignment_group', test123.support_group);
}
This worked fine.
Make sure that in your custom table the assignment group field is a reference to the sys_user_group table. If it's anything else, then it's not going to work.
Also, don't use name like "test123.u_assignment_group.name". Make sure to use the sys_id. You'll get that as the value automatically when dotwalking to the group field (like in my example script).
[EDIT] I just re-read your post and figured that I misunderstood something. If all your fields in the custom table are string fields, then that doesn't work. Your group should be a reference or you'd have to use GlideAjax to query for the user group based on name and then return the sys_id of the group as the value to use.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 03:46 AM - edited 04-26-2023 03:51 AM
Try like this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var test123= g_form.getReference('u_service', getApp);
}
function getApp(test123) {
g_form.setValue('category', test123.u_category);
g_form.setValue('subcategory', test123.u_subcategory_1);
g_form.setValue('u_subcategory', test123.u_subcategory_2);
g_form.setValue('u_subcategory', test123.u_subcategory_2);
}
Please be kind enough to mark my answer helpful and accept as Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 03:51 AM
Hi Karan,
Please use the below , getReference requires a callback function to achieve this.
var serviceref = g_form.getReference('u_service', getService);
function getService(serviceref){
g_form.setValue('category', serviceref.field_name.toString());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 04:08 AM - edited 04-26-2023 04:16 AM
Technically there shouldn't be a problem.
It's recommended to use a callback function with getReference, but that's not breaking it even if you don't.
In your example you're not setting the assignment group so it's hard to say what's wrong.
I did a test (similar to your script) for cmdb_ci field on incident form. When the value is changed it should take the support group and populate it as the assignment group on the incident form.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var test123 = g_form.getReference('cmdb_ci');
g_form.setValue('assignment_group', test123.support_group);
}
This worked fine.
Make sure that in your custom table the assignment group field is a reference to the sys_user_group table. If it's anything else, then it's not going to work.
Also, don't use name like "test123.u_assignment_group.name". Make sure to use the sys_id. You'll get that as the value automatically when dotwalking to the group field (like in my example script).
[EDIT] I just re-read your post and figured that I misunderstood something. If all your fields in the custom table are string fields, then that doesn't work. Your group should be a reference or you'd have to use GlideAjax to query for the user group based on name and then return the sys_id of the group as the value to use.