- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 05:50 AM
Hi ServiceNow Community Developers,
Do you know if there is a way to use an advanced reference qualifier in a reference field on a UI page? I know you can specify a query that you would like to apply to the lookup table however in my use case the query won’t work because the data that I would like to see from the lookup table is dependent on the data that is in another table. In a normal ServiceNow form in the core platform this kind of functionality is achieved by specifying Advanced in the “Use reference qualifier” field and then just below that in the “Reference qual” field you specify the script include that you would like to call to return the data you want to see in a related list view. I am basically looking for this kind of functionality however I am not sure how to go about doing this in a ui page.
Kindly advise please.
Thanks,
Johannes
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 06:56 PM
Here is the solution to my question above - https://www.servicenow.com/community/itsm-forum/call-advanced-reference-qualifier-from-ui-page/m-p/4...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 06:37 AM
you can make g:ui_reference query as dynamic
what's your current UI page and what's required?
check this link where I shared something similar 6 years ago
this link as well
Store value in reference field of ui page using client script
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
11-09-2023 06:32 PM
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<!-- CSS Styling -->
<style>
td {
padding: 1px;
}
</style>
<!-- Get the values from dialog preferences -->
<g:evaluate var="jvar_incident_id_text" expression="RP.getWindowProperties().get('incident_id')" />
<g:evaluate var="jvar_short_descr" expression="RP.getWindowProperties().get('short_descr')" />
<g:evaluate var="jvar_descr" expression="RP.getWindowProperties().get('descr')" />
<g:evaluate var="jvar_priority" expression="RP.getWindowProperties().get('priority')" />
<g:evaluate var="jvar_inc_num" expression="RP.getWindowProperties().get('inc_num')" />
<g:evaluate var="jvar_client" expression="RP.getWindowProperties().get('client')" />
<g:evaluate var="jvar_issue_creator" expression="RP.getWindowProperties().get('issue_creator')" />
<g:evaluate var="jvar_incident_creator" expression="RP.getWindowProperties().get('incident_creator')" />
<g:evaluate var="jvar_solution" expression="RP.getWindowProperties().get('solution')" />
<g:evaluate var="jvar_functional_component" expression="RP.getWindowProperties().get('functional_component')" />
<g:evaluate var="jvar_component" expression="RP.getWindowProperties().get('component')" />
<g:evaluate var="jvar_eagle_version" expression="RP.getWindowProperties().get('eagle_version')" />
<g:evaluate var="jvar_affects_versions" expression="RP.getWindowProperties().get('affects_versions')" />
<!-- Set up form fields and labels -->
<div class="outputmsg outputmsg_info notification notification-info" style="color:#666666">Please note - Clicking OK will create a Jira issue with all the fields shown in the form below. If you want to change any of the read only fields below please click Cancel to go back to the incident form and change them there. </div><br />
<div class="formPadding">
<form role="form">
<table width="650px">
<tr><td>
<div id="incidentNum_container" class="form-group is-required form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Service Now ID:</g:form_label>
</div>
<div class="col-md-7 text-right">
<input id='incidentNum' name='incidentNum' type='text'
required="true" class="form-control" onkeyup="inputChanged('incidentNum')" value="${jvar_inc_num}" readonly="true"> </input>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="project_container" class="form-group is-required form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Project:</g:form_label>
</div>
<div class="col-md-7">
<g:ui_reference id='project' name='project' table="x_eais_custom_tabl_jira_project" required='true' class="form-control" onchange="getProjectIssueTypes('project')"/>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="issueType_container" class="form-group is-required form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>${gs.getMessage("Issue type:")}</g:form_label>
</div>
<div class="col-md-7">
<select id='issueType' name='issueType' class="form-control" onchange="inputChanged('issueType')">
<option value="">-- Select --</option>
</select>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="shortDescr_container" class="form-group is-required form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Summary:</g:form_label>
</div>
<div class="col-md-7 text-right">
<input id='shortDescr' name='shortDescr' type='text'
required="true" class="form-control" onkeyup="inputChanged('shortDescr')" value="${jvar_short_descr}"> </input>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="description_container" class="form-group is-required form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Description:</g:form_label>
</div>
<div class="col-md-7 text-right">
<textarea id='description' name='description' type='textarea'
required="true" class="form-control" rows="10" style="height:100%;" onkeyup="inputChanged('description')" > ${jvar_descr} </textarea>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="client_container" class="form-group is-required form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Requesting Client:</g:form_label>
</div>
<div class="col-md-7 text-right">
<input id='client' name='client' type='text'
required="true" class="form-control" onkeyup="inputChanged('client')" value="${jvar_client}" readonly="true"> </input>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="priority_container" class="form-group is-required form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Priority:</g:form_label>
</div>
<div class="col-md-7">
<select id='priority' name='priority' class="form-control" onchange="inputChanged('priority')">
<option value="">-- Select --</option>
<option value="Highest">Highest</option>
<option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>
<option value="Lowest">Lowest</option>
</select>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="solution_container" class="form-group is-required form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Solution:</g:form_label>
</div>
<div class="col-md-7 text-right">
<input id='solution' name='solution' type='text' required="true"
class="form-control" onkeyup="inputChanged('solution')" value="${jvar_solution}" readonly="true"> </input>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="functional_component_container" class="form-group is-required form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Functional component:</g:form_label>
</div>
<div class="col-md-7 text-right">
<input id='functional_component' name='functional_component' type='text' required="true"
class="form-control" onkeyup="inputChanged('functional_component')"
value="${jvar_functional_component}" readonly="true"> </input>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="component_container" class="form-group is-required form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Component:</g:form_label>
</div>
<div class="col-md-7 text-right">
<input id='component' name='component' type='text' required="true"
class="form-control" onkeyup="inputChanged('component')"
value="${jvar_component}" readonly="true"> </input>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="eagleVersion_container" class="form-group form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Eagle version:</g:form_label>
</div>
<div class="col-md-7 text-right">
<input id='eagleVersion' name='eagleVersion' type='text'
class="form-control" onkeyup="inputChanged('eagleVersion')" value="${jvar_eagle_version}"> </input>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="issueCreator_container" class="form-group form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Reporter:</g:form_label>
</div>
<div class="col-md-7 text-right">
<input id='issueCreator' name='issueCreator' type='text'
class="form-control" onkeyup="inputChanged('issueCreator')" value="${jvar_issue_creator}" readonly="true"> </input>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="incidentCreator_container" class="form-group form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Watcher:</g:form_label>
</div>
<div class="col-md-7 text-right">
<input id='incidentCreator' name='incidentCreator' type='text'
class="form-control" onkeyup="inputChanged('incidentCreator')" value="${jvar_incident_creator}"> </input>
</div>
</div>
</td>
</tr>
<tr><td>
<div id="affectsVersions_container" class="form-group form-horizontal">
<div class="col-md-4 text-right">
<g:form_label>Affects versions:</g:form_label>
</div>
<div class="col-md-7 text-right">
<input id='affectsVersions' name='affectsVersions' type='text'
class="form-control" onkeyup="inputChanged('affectsVersions')" value="${jvar_affects_versions}" readonly="true"> </input>
</div>
</div>
</td>
</tr>
</table>
<div class="form-group">
<input type="hidden" class="form-control" name="incidentSysId" id="incidentSysId" value="${jvar_incident_id_text}"></input>
<input type="hidden" class="form-control" name="incPriority" id="incPriority" value="${jvar_priority}"></input>
</div>
<div align="center">
<g:dialog_buttons_ok_cancel ok="return validateInfo()" cancel="return onCancel()" />
</div>
</form>
</div>
</g:ui_form>
</j:jelly>
Hi Ankur,
Thanks for your response.
So in my use case there is only one ui_reference field. It references a jira project table as shown in the screenshot. There is however another table called jira metadata that has a project field which is a reference to the jira table that I want data from. So when I click the reference icon (the magnifying glass) on the ui page popup, on the lookup related list that appears I would like to see only jira project that are also on the metadata table. In other words I need to something GlideRecord to the metadata table and say if project from jira table matches project from metadata table (match is by sys_id since project field on metadata is a reference to jira project) then return only those jira projects on the lookup list view. In a ServiceNow core platform form I could easily do this using a script include that I would call from a reference qualifier however in the ui page I find this very challenging to do.
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 06:56 PM
Here is the solution to my question above - https://www.servicenow.com/community/itsm-forum/call-advanced-reference-qualifier-from-ui-page/m-p/4...