UI Page: Changing of Value on a Reference field based on another Reference field in same page

Kapil Chopra
Tera Contributor

I want to Change value of the group div based on the location div in this UI page ,also I will have glide another table to get the group information. Please suggest how can I achieve this.

 

 

<g:ui_form>

<table width="100%">

<tr id="locationrow" >
		<td>
<div class="form-group form-horizontal">
	<div class="col-md-4 text-center">
		<g:form_label>
			${gs.getMessage('Location')}
		</g:form_label>
	</div>
	<div class="col-md-8 text-center">
	   <j:set var="jvar_loc_sysids" value="${RP.getWindowProperties().get('sysparm_sysIDs')}"/>
		<g:ui_reference name="location_ref_field" query= "sys_idIN${jvar_loc_sysids}" table="cmn_location" mandatory='true'  />
	</div>
</div>	
 <hr/>
 
<div class="form-group form-horizontal">
	<div class="col-md-4 text-center">
		<g:form_label>
			${gs.getMessage('Group ')}
		</g:form_label>
	</div>
	<div class="col-md-8 text-center">
	   <j:set var="jvar_group_sysids" value="${RP.getWindowProperties().get('sysparm_sysIDs')}"/>
		<g:ui_reference name="group_ref_field"  table="sys_user_group" mandatory='true'  />
	</div>
</div>			
		</td>

	</tr>
	


	<tr id ="poll_img" style="display:none" border="1">
		<td colspan="2"  align="center" width="300px">
                       
			<img src="./images/ajax-loader.gifx" alt="${gs.getMessage('Please Wait')}" />
                        <p id="poll_text" style="font-weight:bold;">
				${gs.getMessage('Please Wait')}
			</p>             
		</td>
	</tr>
        <tr><td colspan="2"><br /></td></tr>
        <tr id="dialogbuttons"><td colspan="2" align="right">
                <g:dialog_buttons_ok_cancel ok="return NewItem()" />
            </td>
        </tr>
</table>
</g:ui_form>

 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Kapil Chopra 

you can have onChange event on 1st one and set the filter to 2nd one

check this link where I shared solution; enhance it for your requirement

Reference field dependency on UI Page 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks Ankur,I have made some progress ,however I need to set value .I guess I have to make changes

 

Could you suggest what changes I need to make to this line.
 

 

function getGroupSysid(){
var locationSysid = gel('location_ref_field').value;
var groupSysid = gel('group_ref_field').value;
alert("locationSysid"+locationSysid);
var userArray = "5a1c71ba1501db8c91e0ebb356c";
groupSysid.setAttribute('onclick',"mousePositionSave(event); reflistOpen( 'userRecords', 'not', 'sys_user', '', 'false','QUERY:active=true','sys_idIN" + userArray+ "', '')");
}

 

@Kapil Chopra 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar ,how can we set the value in the 2nd Reference field