Dynamic reference field filter in UI page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2021 02:15 AM
Hello Experts,
I am having one UI page in which one reference field filter is managed in <g:evaluate> tag as below,
This works fine while loading( it applies proper filter which we want) but now new requirement is to change that reference filter based on one checkbox selection which will be on same UI page.
Any help would be appreciated.
Thanks.
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2021 04:22 AM
Hi,
Did you try adding alert in that function and check
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2021 04:29 AM
Hi Ankur,
Filter is gettingapplied with above code but when we click on search icon and open pop up window at that time it is not allowing me to select any of the record for reference field.
Can you suspect if anything wrong with code as I'm not sure what parameters 'attribute' function needs, let me know if you have any document link for the function.
Thanks.
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2021 04:47 AM
Hi,
you are setting the QUERY as QUERY:null inside the if condition
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2021 02:37 AM
Hi,
In short you will have to use onChange attribute for your html choice
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2021 02:38 AM
Hi,
You can use it.
UI Page
<div class="form-group" id="rack_row">
<label class="control-label col-xs-3"><span title="" aria-label=""
mandatory="true" class="required-marker" style="display:inline;"></span>
<span class="label-text" style="display:inline;">Rack</span></label>
<div class="col-md-4">
<g:ui_reference name="first1" id="first1" table="cmdb_ci_rack" onchange="setReferenceField();" />
</div>
</div>
<div class="form-group" id="start_upos_row">
<label class="control-label col-xs-3"><span title="" aria-label=""
mandatory="true" class="required-marker" style="display:inline;"></span>
<span class="label-text" style="display:inline;">Position</span></label>
<div class="col-md-4">
<g:ui_reference name="first2" id="first2" table="cmdb_poss" completer="AJAXTableCompleter" />
</div>
</div>
Client Script
function setReferenceField(){
var firstReferenceFieldSysId = gel('first1').value;
var secondReferenceFieldLookUp = gel('lookup.first2');
var endUpos = gel('lookup.end_upos');
secondReferenceFieldLookUp.setAttribute('onclick',"mousePositionSave(event); reflistOpen( 'first2', 'not','u_u_position', '', 'false','QUERY:status=', 'u_rack=" + firstReferenceFieldSysId + "^u_in_use=false', '')");
$('sys_display.first2').setAttribute('onfocus',"if (!this.ac) new AJAXReferenceCompleter(this, 'first2', '', 'QUERY:u_rack="+firstReferenceFieldSysId+"^u_in_use=false', 'u_u_position');");
endUpos.setAttribute('onclick',"mousePositionSave(event); reflistOpen( 'end_upos', 'not','u_u_position', '', 'false','QUERY:status=', 'u_rack=" + firstReferenceFieldSysId + "^u_in_use=false', '')");
$('sys_display.end_upos').setAttribute('onfocus',"if (!this.ac) new AJAXReferenceCompleter(this, 'end_upos', '', 'QUERY:u_rack="+firstReferenceFieldSysId+"^u_in_use=false', 'u_u_position');");
}