Filter Approvers based on selected RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 05:06 PM - edited 02-03-2025 05:22 PM
Hello All,
In the below screenshot, we need to show approvers in 'Select Approver' field based on selected RITM in the 'Select RITM' field.
Need help on reference qualifier script on 'Select Approver' field so that it shows approvers that belong to the selected RITM.
I tried below but not working.
Any help is appreciated.
Thanks,
Rocky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 07:00 PM
Hi @Rocky5
Change the reference qualifier as below. Please change the variable name as per your Select RITM field. In my case, I have considered Select RITM field internal name as ritm.
javascript:'sysapproval=' + current.variables.ritm;
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 07:11 PM
you can use this in advanced ref qualifier
Ensure you give correct variable name here
javascript: 'sysapproval=' + current.variables.ritmVariableName + '^ORdocument_id=' + current.variables.ritmVariableName;
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
02-04-2025 08:08 AM
Hi, I believe your case is better suited for a Client Script rather than a dynamic qualifier. If you'd like to give it a try, create a new Client Script with these properties:
Name: [your_choice]
Table: [sc_req_item]
Type: onChange
Field name: select_ritm_field
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var itemReference = g_form.getReference('select_ritm_field'); // Get selected Request Item
if (itemReference) {
var grApproval = new GlideRecord('sysapproval_approver');
grApproval.addQuery('sysapproval', itemReference.sys_id);
grApproval.orderBy('sys_created_on');
grApproval.query();
if (grApproval.next()) {
g_form.setValue('select_approver', grApproval.approver.toString());
} else {
g_form.setValue('select_approver', '');
}
} else {
g_form.clearValue('select_approver'); // Clear field if no Request Item selected
}
}
I hope this helps. Excited to hear back about your solution, as this was a bit of a learning process for me as well.
If I've at all helped, please return the favor by clicking the thumb next to my post. Thanks!