UI Page: Changing of Value on a Reference field based on another Reference field in same page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 09:01 PM
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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 10:58 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 04:43 AM
Thanks Ankur,I have made some progress ,however I need to set value .I guess I have to make changes
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+ "', '')");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 05:12 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 08:35 AM
@Ankur Bawiskar ,how can we set the value in the 2nd Reference field