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

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


Hi Mark,


Could you please explain what sort of expression is this?



$(g_form.getTableName())


The '$' symbol is a prototype dom selector.   The prototype library is something that has been included in ServiceNow for years and can make these types of client-side scripting exercises much simpler.   It's basically the equivalent to 'gel' or 'document.getElementByID' in javascript.   Everything within that is just the ID of that dom element on the page.   The end result is this...



$('incident.watch_list_nonedit');



That will return the HTML element with the ID indicated as an object.   At that point, you can access the attributes, one of which is 'innerHTML' (which contains the information on the selected options in this case).



Here is a link to the prototype documentation...



Prototype v1.7.2 API documentation | $


Thanks a lot Mark for detailed clarification on this. DOM area   is still newer thing to me


I was wondering seeing these expressions in CSS style sheet as well and couldn't related it to JEXL. I hope those are the same Prototype DOM selectors as well.