Set Value To Glide List

billv6
Kilo Expert

Hello All,

 

One more little issue, this time with glide list, here is the thing: I need to set a value to a glide list when a boolean field is true but with the examples I've got on ServiceNow Wiki I'm not able to do that, look:

 

find_real_file.png

 

 

I have these two fields in the user form, "u_ffic_manager" and "u_authorized_approver_for". In the "u_authorized_approver_for" field, I have today only one value (Request):

 

find_real_file.png

 

 

 

I'm trying to create a simple script for when the "u_ffic_manager" field is true, the "Request" value is set to "u_authorized_approver_for" field for the specific user, but I'm having no luck on that:

 

find_real_file.png

 

 

Here is the script:

 

find_real_file.png

 

 

Any ideas on how to set this?

 

Thanks!

 

Milton P. Silva Junior

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Milton,



You're mixing client and server side code there. If you want to do this as a server side before business rule like your screenshot, you can just do this without g_form as that is a client side method:



if (current.u_ffic_manager == true) {


  current.u_authorized_approver_for = "sys_id"; //you could also do current.u_authorized_approver_for.setDisplayValue('Display of the user');


}



If you wanted to do it client side you could put an onchange client script on the ffic manager field and do something like:



if (newValue == 'true') {


g_form.setValue('u_authorized_approver_for', 'sysid');  


}


View solution in original post

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Milton,



You're mixing client and server side code there. If you want to do this as a server side before business rule like your screenshot, you can just do this without g_form as that is a client side method:



if (current.u_ffic_manager == true) {


  current.u_authorized_approver_for = "sys_id"; //you could also do current.u_authorized_approver_for.setDisplayValue('Display of the user');


}



If you wanted to do it client side you could put an onchange client script on the ffic manager field and do something like:



if (newValue == 'true') {


g_form.setValue('u_authorized_approver_for', 'sysid');  


}


Hi Brad,



Thanks for helping, you are right, my mistake, but even the code you posted apparently is not working, when I save the user form with Business Rule debug enabled, I've got this:



find_real_file.png




But when I look at the glide list, there is nothing there:



find_real_file.png



The "Request" option should be there, like this:



find_real_file.png


Brad Tilton
ServiceNow Employee
ServiceNow Employee

Make sure it's a before update business rule. Could you post a screenshot of it as well?


You are the man!!! 🙂



I have been using "after" business rule, just changed it to "before" and it is working like a charm!



Thank you so much Brad!