Hide Opened_For from the Assigned To Choice Selection for HR Case
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 07:40 PM
Hide Opened_For from the Assigned To Choice Selection for HR Case
Wrote onLoad Client Script but it didnt work.
function onLoad() {
// Get the 'Opened For' user's sys_id
var openedForUserSysId = g_form.getValue('opened_for');
// Get the HR Service value
var hrServiceValue = g_form.getValue('hr_service');
// Get the Assignment Group
var assignmentGroup = g_form.getValue('assignment_group');
// Check if the HR Service and Assignment Group match the specified values
if (hrServiceValue == '2bd814771ba38dd0d1a59938b04bcbc8' && assignmentGroup == 'b25370019f22120047a2d126c42e705c') {
// Set the reference qualifier to exclude the 'Opened For' user
var referenceQualifier = 'sys_id!=' + openedForUserSysId;
// Apply the reference qualifier to the 'assigned_to' field
g_form.setReferenceQualifier('assigned_to', referenceQualifier);
// Check if the 'assigned_to' field is pre-populated with the 'Opened For' user and clear it if necessary
var assignedToValue = g_form.getValue('assigned_to');
if (assignedToValue == openedForUserSysId) {
// Clear the 'assigned_to' field if it contains the 'Opened For' user
g_form.setValue('assigned_to', '');
}
}
}
Can you please let me know if there is anything wrong in the code or any other method to achieve this logic.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2024 09:41 AM
Here's a post where someone solved for the same thing. It looks like you'll need a script include and an Advanced Reference Qualifier on the field. Here is a link to the docs on reference qualifiers.
If you're trying to do this on a catalog item, reference this post.