Is is possible to define a dependent field in a UI page for a <g:ui_choicelist element?

SS132314
Kilo Contributor

Hi,

I currently have a <g:ui_choicelist element in my UI page that brings back all the options from the field I am querying however I only need to see a filtered list of these choice options based on a dependent field.

Is there a way to define the dependent field on the <g:ui_choicelist element so that it only brings back the options that are dependent on a hidden string field 'Parent type' that I have on the form?

This is currently what I am seeing on the front end.

This list on the actual form is much shorter

See below for the scripts I have so far (Filtered it down to the relevant parts). Any guidance would be much appreciated.

UI Page HTML

<table id="task_close_incomplete" width="100%">
    <colgroup>
        <col />
        <col />
    </colgroup>
    <tr>
        <td class="left">
            <span title="${gs.getMessage('Mandatory - must be populated before Submit')}" mandatory="true" oclass="mandatory" style="background-color:#C00;color:#C00;margin-right:3px;margin-left:1px;">I</span>
            <label for="clear_code">${gs.getMessage("Clear code")}</label>
        </td>
        <td align="right" style="padding: 0 0 4px 8px;">
            <g:ui_choicelist name='clearCode' table='wm_task' field='u_clear_code' />
        </td>
    </tr>
    <tr>
        <td colspan="2" id="clear_code_error" style="display: none">
            <img src='images/outputmsg_error.gifx' alt=''/>${gs.getMessage("Please provide a clear code")}
            </td>
    </tr>
</table>

 

UI Page Client Script

function submitChanges() {
    var clearCode = gel('clearCode').value;
    if (clearCode.length < 1) {
        document.getElementById('clear_code_error').style.backgroundColor = "#FFEBE8";
        document.getElementById('clear_code_error').style.display = "block";
        return false;
    } else {
        document.getElementById('clear_code_error').style.display = "none";
        g_form.setValue('u_clear_code', clearCode);
        g_form.save();
    }

    GlideAjax.disableSessionMessages();
    return true;
}

 

UI Action

function openFollowOnPopUp(){
	var dialogClass;
    try {
    	 dialogClass = GlideModal;
    } catch(e) {
    	dialogClass = GlideDialogWindow;
    }
	var dialog = new dialogClass("service_management_task_closed_incomplete");
    dialog.setWidth("550");
	dialog.setTitle("Close Incomplete");
	dialog.setPreference("sys_id", g_form.getUniqueValue());
	dialog.setPreference("work_notes", g_form.getValue("work_notes"));
	dialog.setPreference("state_flow_id", "41dfa2e0d7630100fceaa6859e61035d");
	dialog.render(); //Open the dialog
}
1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

You can try using the query tag inside the g:ui_choicelist but I am not sure if it can be dynamic.

If that does not work, then I will advise you can switch to a normal HTML select tag and populate the choices manually.

View solution in original post

2 REPLIES 2

Kalaiarasan Pus
Giga Sage

You can try using the query tag inside the g:ui_choicelist but I am not sure if it can be dynamic.

If that does not work, then I will advise you can switch to a normal HTML select tag and populate the choices manually.

Resorted to the HTML select tag in the end. Not ideal but I don't see any other option. Thanks.