Displaying GlideRecord results in a HTML select element

J A Lindsay
Giga Guru

Hi,

I'm trying to display a list of catalog items in a dialog window. The dialog window itself works fine, but the list of catalog items is only coming up with the default value set in the HTML of the UI Page.

 

Any thoughts?

Thanks in advance!

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_sys_id" expression="RP.getWindowProperties().get('sys_id')" />
<j2:set var="jvar_hide_response_time" value="true" />
	<g:evaluate>
        var buttonLabelOk = gs.getMessage("Confirm");
        var buttonLabelCancel = gs.getMessage("Cancel");
        var body = gs.getMessage("Please select a catalog item:");
    </g:evaluate>
    <p id="modal_body">${HTML:body}</p>
    <div id="modal_footer" class="modal-footer">
        <g:evaluate>
            var gr = new GlideRecord('sc_cat_item');
            gr.query();
        </g:evaluate>
        <select id="catalog_item_select">
            <option value="">-- Select Catalog Item --</option>
            <g:while glideRecord="${gr.next()}">
                <option value="${gr.sys_id}">${gr.getDisplayValue('name')}</option>
            </g:while>
        </select>
		<g:dialog_buttons_ok_cancel ok_text="${JS:buttonLabelOk}" ok_title="${JS:buttonLabelOk}" ok="return confirm_quote();" ok_style_class="btn btn-primary" 
		cancel_text="${JS:buttonLabelCancel}" cancel_title="${JS:buttonLabelCancel}" cancel_style_class="btn btn-danger" cancel="return cancel();" cancel_data_dismiss="modal"/>
	</div>
</j:jelly>

 

This is what displays when I click the UI Action that triggers the UI Page to show:

JALindsay_0-1715600446087.png

 

1 ACCEPTED SOLUTION

Hi Kieran, Thanks for your reply, I actually changed my approach, and copied the acl_role_picker UI Page, and used a reference field instead. - This works for my purposes as well as the list would have.
Thanks so much for the prompt reply. 

View solution in original post

2 REPLIES 2

Kieran Anson
Kilo Patron

Hey,

Change your evaluation of catalog items to phase 2

<g2:evaluate>
            var gr = new GlideRecord('sc_cat_item');
            gr.query();
        </g2:evaluate>

and then for your while condition, you need to use the jelly namespace

<j2:while glideRecord="${gr.next()}">
                <option value="${gr.sys_id}">${gr.getDisplayValue('name')}</option>
            </j2:while>

Hi Kieran, Thanks for your reply, I actually changed my approach, and copied the acl_role_picker UI Page, and used a reference field instead. - This works for my purposes as well as the list would have.
Thanks so much for the prompt reply.