g_form.SetValue() not set the value on record. After record submit value is EMPTY -- Kingstone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 06:32 AM
I have Category, Type and Item based on these values i am getting approving manager. for getting approving manager i had custom table with same field names. Approving Manager(Ex:Alex,Pradeep,Sharma).
by Glide Record on Custom table in onChange() client script i am getting Manager.
Here issue is after submit the record Approving Manager filed is EMPTY. this issue is after Kingstone Upgrade. below is the sample code.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if(cat == 'Application1' && type == 'Application2'){
var appm = new GlideRecord('u_approvers');
appm.addQuery('u_category' , cat);
appm.addQuery('u_type' , type);
appm.addQuery('u_item' , item);
appm.query();
while (appm.next()){
g_form.setValue('u_approving_manager', appm.u_manager);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 06:36 AM
First thing - it is not best practice to use GlideRecord in client scripts.
Use GlideAjax class and fetch the value.
https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/reference/r_GlideAjax.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 06:40 AM
Hi Raheem,
I would recommend creating a variable with the value of the u_manager rather than just using the glide object:
while (appm.next()){
var manager = appm.getValue('u_manager');
g_form.setValue('u_approving_manager', manager);
}
I would also recommend using glide ajax to call the server to run the glide query, when you run a glide record in the client in retrieves the whole record rather than just the value you want. Also, if u_approving_manager is a reference field and you're only giving it a sys_id, it will make another call to the server to retrieve the display value.
Cheers
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 07:25 AM
u_approving_manager is glide_list type and reference user table.
I got the users list like
Approving Manager: Alex,Pradeep,Sharma
But the issue is after submit Approving Manager field is EMPTY. That is the issue. This issue came after upgrade to King stone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2018 04:07 AM
Hello raheem
I am facing the same. issue . you got any solution till now ??