How to get the display value of the glide list from Client Script?

Haritha Marathi
Tera Contributor

Hi,

Can any one tell me how to get the display value of a Glide list from a client script?

Thanks in advance!!

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

This should work.   Just replace 'watch_list' with the name of your field.



var fieldName = 'watch_list';


var options = $(g_form.getTableName() + '.' + fieldName + '_nonedit').innerHTML;


alert(options);


View solution in original post

9 REPLIES 9

Thanks Mark.   I'm trying to capture the list values as the user is changing them, and then take action using a client script.   However, $(g_form.getTableName() + '.' + fieldName + '_nonedit').innerHTML only gets the values that were first loaded with the form, not the new ones that the user is selecting.



Is there a way to get the new values?   Without having to use AJAX or some kind of server-side code?


Haritha Marathi
Tera Contributor

Thanks a lot Mark, it worked


Haritha Marathi
Tera Contributor

Hi Mark,


This will work when the field is there on the form, if it is hidden then how can we get? Is there any way to fetch the display value from the table?


You get the display value from back-end scripts using 'current.fieldName.getDisplayValue()'.   You could use a 'display' business rule to pass that information to the client if the field wasn't on the form.   You can refer to the wiki for information on 'display' business rules.


Trevor Muhl
Kilo Sage

In certain contexts, such as a scoped application, the "$" or "gel" functions are not available. The following code provided the solution I needed:

var fieldName = 'x_my_field_name';
var selector = '[id="' + g_form.getTableName() + '.' + fieldName + '_nonedit"]';
var displayValue = g_document.getElement(selector).innerText;

For more information about "g_document", please refer to the GlideDocumentV3 documentation.