- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 11:39 AM
I am struggling with how to add an advanced reference qualifier for the UI Action "Assess" on the sn_risk_risk table.
When you click Assess it loads a UI Page Modal with a Popup to Select the Assessor and Approver.
I need to set a reference qualifier or filter on the Assessor so that only the users that are in the same department as the Risk Owners Department are listed.
If someone can assist please with some direction on how to achieve this.
This is for Risk and creating a risk assessment. [GRC]
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 02:25 PM - edited 02-20-2025 09:27 PM
Hello,
first I have to mention best practice to customizing out-of-box records is to make a copy and deactivate OOB record. So here are steps according to the best practice:
Customizing UI Action
1. Open UI Action 'Assess' (Sys ID: 9859522b77073010c4a4b0bdbd5a9916)
2. Make a copy: Open additional action menu and click on 'Insert and Stay', it will open new record
3. Delete all code in Script field, paste this one:
function showAssessorApproverModal() {
//Check if there is an assessment in draft state created from scope
if (!g_scratchpad.draftAsmt) {
(function() {
g_form.getReference('owner', openModal);
})();
function openModal(owner) {
var ownerDepartment = owner.getValue('department');
var modal = new GlideModal('sn_risk_advanced_assign_assessor_approver_risk_custom');
modal.setTitle(getMessage('Add Assessor and Approver'));
modal.setPreference("department", ownerDepartment);
modal.setBackdropStatic(true);
modal.render();
}
} else {
gsftSubmit(null, g_form.getFormElement(), 'risk_assess_adv');
}
}
if (typeof window == 'undefined') {
var count = new sn_risk_advanced.RiskAssessmentUtils().markAssess(new sn_risk_advanced.RiskUtilities().checkIfAsmtInDraft(current));
if (count == 1) {
gs.addInfoMessage(gs.getMessage("The assessment is successfully initiated. The assessors and approvers for this assessment are as specified in the risk assessment scope."));
}
action.setRedirectURL(current);
}
4. Save it
5. Open OOB UI Action (Sys ID: 9859522b77073010c4a4b0bdbd5a9916)
6. Set checkbox 'Active' to false (unchecked)
Customizing UI Page
1. Open UI Page 'assign_assessor_approver_risk' (Sys ID: a74d56eb77073010c4a4b0bdbd5a9990)
2. Make a copy: Open additional action menu and click on 'Insert and Stay', it will open new record
3. Change value in field 'Name' to assign_assessor_approver_risk_custom
4. Delete all code in HTML field, paste this one:
<?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:evaluate>
var department = RP.getWindowProperties().department || RP.getParameterValue('department');
var newAssessorRefQual = 'roles=sn_risk_advanced.ara_assessor^department=' +
department +'^active=true^EQ';
</g:evaluate>
<style>
#assign_assessor_approver .required-marker {
display: inline-block;
}
</style>
<div class="row">
<div class="form-horizontal" id="assign_assessor_approver">
<div class="form-group">
<label id="assessor_label" class="col-sm-3 col-sm-offset-1 control-label"><span id="assessor_span" mandatory="true" class="required-marker"></span>${gs.getMessage('Assessor')}</label>
<div class="col-sm-6" aria-label="assessor">
<g:ui_reference name="assessor" id="assessor" table="sys_user" field="name" query="${newAssessorRefQual}" onchange="checkMandatoryFields(this)" />
</div>
</div>
<div class="form-group">
<label id="approver_label" class="col-sm-3 col-sm-offset-1 control-label"><span id="approver_span"></span>${gs.getMessage('Approver')}</label>
<div class="col-sm-6" aria-label="approver">
<g:ui_reference name="approver" id="approver" table="sys_user" field="name" query="roles=sn_risk_advanced.ara_approver^active=true^EQ" />
</div>
</div>
<div class="form-group">
<label id="days_label" class="col-sm-3 col-sm-offset-1 control-label"><span id="days_span" mandatory="true" class="required-marker"></span>${gs.getMessage('Days to overdue')}</label>
<div class="col-sm-6">
<input aria-label="Days to overdue" id="days" name="days" type="number" min="1" value="5" class="form-control" onchange="enableSubmitButton()"></input>
</div>
</div>
<div class="modal-footer">
<div class="row">
<div class="col-sm-6 clearfix pull-right">
<button class="btn btn-default" onclick="handleCancel()">${gs.getMessage('Cancel')}</button>
<button id="submit" class="btn btn-primary disabled" tabindex="-1" aria-disabled="false" onclick="handleSubmit()">${gs.getMessage('Submit')}</button>
</div>
</div>
</div>
</div>
</div>
</j:jelly>
It should work as required, only users with the same value 'Department' as has a user selected in 'Owner' field.
If my answer helped you, please mark it as correct and helpful, thank you 👍
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 07:19 PM
from the UI action you need to pass the department of owner and then within the UI page make the code changes as shared in the link above
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