g_form.SetValue() not set the value on record. After record submit value is EMPTY -- Kingstone

raheem2
Kilo Explorer

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);
}
}

}

 

7 REPLIES 7

Midhun1
Giga Guru

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

Dubz
Mega Sage

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

raheem2
Kilo Explorer

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. 

ruchika2353
Kilo Contributor

Hello raheem

I am facing the same. issue . you got any solution till now ??