How to clear reference field value on UI Page

Madankumar N1
Tera Contributor

Hi 

I have one UI Page in that i have 2 fields one is reference " approver "to User group and one is "Type" choice list.

when i select on Type choice value based on choice "approver "field reference field will get details

after select group name i changed the type approver value is getting clear but following am getting issue 

highligted in red color is not clearing

find_real_file.png

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Madan,

Can you share your script and explain in detail what is your requirement and what is causing the issue?

Regards

Ankur

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

This is my jelly script 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<style>
.fieldmsg-container {
margin-bottom: 40px;
}
</style>
<g:ui_form>
<j:set var="jvar_change_request" value="${RP.getWindowProperties().get('sysparm_changerequest')}" />

<table width="100%" class="table single-approvers">
<tbody>
<tr>
<td>
<div style="display: inline-block;">
<button type="button" class='btn btn-primary icon-add' onclick="addnew('approver')"></button></div>
<div style="font-size: 23px; display:inline-block; vertical-align: middle">Approvers</div>
<div style="margin-top: 8px">Approver:</div>
</td>
<td style="vertical-align: bottom">
<span>Approver Type:</span>
</td>
<td>
$[SP]
</td>
</tr>
<tr id="approver_user_row">
<td width="60%">
<g:ui_reference name="approver_user" id="approver_user" table="sys_user" query="active=true" completer="AJAXTableCompleter" />
</td>
<td width="40%">
<select class="form-control" name="approver_type" id="approver_type" onchange="setMyReference('approver_user', this.id)">
<option value="individual_approver">Individual Approver</option>
<option value="responsible_manager">Responsible Manager</option>
<option value="accountable_director">Accountable Director</option>
</select>
</td>
<td>
<button type="button" class="btn btn-danger icon-remove" id="approver_user_btn" onclick="removeApprover(this)" />
</td>
</tr>
</tbody>
</table>
<table width="100%" class="table group-approvers">
<tbody>
<tr>
<td>
<div style="display: inline-block;">
<button type="button" class='btn btn-primary icon-add' onclick="addnew('agroup')"></button>
</div>
<div style="font-size: 23px; display:inline-block; vertical-align: middle">Group Approvers</div>
<div style="margin-top: 8px">CRG Approver Group:</div>
</td>
<td style="vertical-align: bottom">
<span>Approver Group Type:</span>
</td>
<td>
$[SP]
</td>
</tr>
<tr id="approver_group_row">
<td width="60%">
<g:ui_reference name="approver_group" id="approver_group" table="sys_user_group" query="active=true^u_crg_type=technical_crg_approver" completer="AJAXTableCompleter" />
</td>
<td width="40%">

<select class="form-control" name="group_approver_type" id="group_approver_type" onchange="setMyReference('approver_group', this.id)">
<option value="technical_crg_approver">Technical CRG</option>
<option value="business_crg_approver">Business CRG</option>
<option value="period_close_crg_approver">Period Close CRG</option>
<option value="special_event_crg_approver">Special Event CRG</option>
</select>
</td>
<td>
<button type="button" class="btn btn-danger icon-remove" id="approver_group_btn" onclick="removeApprover(this, 'group')" />
</td>
</tr>
</tbody>
</table>

<input type="hidden" id="change_request" name="change_request" value="${jvar_change_request}" />
<input type="hidden" id="approver_collection" name="approver_collection" />
<input type="hidden" id="group_collection" name="group_collection" />

<div class="fieldmsg-container" >
<div id="missingChangeRequestError" class="fieldmsg notification notification-error" style="display:none">Change Request context must be present
</div>

<div id="missingApproverUser" class="fieldmsg notification notification-error" style="display:none">All fields must be filled in or removed.
</div>

</div>

<g:dialog_buttons_ok_cancel ok_text="Set Approvers" ok="return checkApprovers();" cancel="return cancel();"/>
</g:ui_form>
</j:jelly>

Tushar Sharma2
Kilo Guru

Hello Madan kumar,

Could you please check the Display value of referenced table that you have selected for approver.

set false whose value is true. Please refer below screen shot.

 

find_real_file.png

 

Regards,

Tushar

DXsherpa

If you are referring the sys_user form then there should not be any entry with true value.

Hit the Correct answer on the impact of response.

Regards,

Tushar

DXSherpa