Can only autopopulate with the 'value' and not the Label

Steve Rondeau
Kilo Expert

I've created a Client script to autopopulate a form based on the original entry.  All in, I'd like to autopopulate 4 fields for alm_consumables. 

I can get two to work, since I've built a reference to another table from which they are retrieved from.  The other two are pulled from choice fields.  I can autopopulate the field but the data is retrieving the value instead of the Label.  

Is there a way to autopopulate the Value?

Client Script

find_real_file.png

Current result:  subclass and substate are not populating properly to populate the alm_consumablesfind_real_file.png

 

 

1 ACCEPTED SOLUTION

Jacob,

The syntax you posted for setValue function is correct, however the problem in this scenario is what to put in the third parameter (Display Value). consume.u_subclass is a choice field and it will only output the value, not the Label and getDisplayValue doesnt work in client scripts. 

My suggestion is :

Either perform a GlideAjax and return the values you want  from server side

OR

Convert the variable types to SELECT BOX with proper type specifications

Thank you

Aman

View solution in original post

11 REPLIES 11

ARG645
Tera Guru
Hi, If you want to retrive Label of a choice field, instead of value, try using getDisplayValue() function. Below is an example: g_form.setValue(“u_subclass”,consume.getDisplayValue(“u_subclass”)); Hope this helps.

Aman, 

 

Thanks for the response.  Unfortunately, this doesn't work.  The field will not populate.  I read that the setDisplayValue doesn't work on the Client side.

You are right, my Bad. I guess in this scneario, you can do a GlideAjax call and return all the values you want from the server side scripts in JSON object. That way you can do a getDisplayValue on the Server side and get the Lable name.

Unfortunately, that's significantly past my scripting ability.