Assigned to field validation based on role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 11:30 AM - edited 09-14-2024 11:33 AM
Hello guys,
I have a requirement when a CIM task type is survey feedback and assigned to a any resolver group, then only users in that resolver group with the Survey Feedback role(resolver_group_manager) should show in assigned to field not all the users in that group should popup.
To Achieve this requirement I have created one script Include and used it in reference qualifier to filter the assigned to users based on the role but it is not working.
Script Include -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 12:21 PM
You can add gs.info or gs.addInfoMessage lines to the SI to confirm the value of taskType and the value of gs.getRoledUsers... (add the log line prior to the return line). If taskType is null or undefined use
javascript: new CustomUserRoleFilter().getFilteredUsers(current.cim_task_type);
in the override reference qualifier. In the Script Include, try
return 'sys_idIN' + getRoledUsers('fmg_resolver_group_manager').join(",");
as this should call a Business Rule, not a gs method. You should also be able to do this within the reference qualifier override
javascript:if(current.cim_task_type == '3'); return 'sys_idIN' + getRoledUsers('fmg_resolver_group_manager').join(",");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 08:31 PM - edited 09-14-2024 08:33 PM
Hi @Brad Bowman ,
I am getting this error when I removed gs from getRoledUsers.
Error MessagegetRoledUsers undefined, maybe missing global qualifier
And your solution made me confused if I have to use script include or only reference qualifier will ne enough to achieve this requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 09:52 PM
In your reference qualifier script include function pass 2nd parameter as below
getFilteredusers(current.getValue("task_type") ,current.getValue("assignment_group"));
then in script include get group like
getFilteredUsers(taskType,task)
{
If (taskType=="3")
var resGroup = task.assignment_group;
if (resGroup)
var userGR = new GlideRecord('sys_user_grmember');
userGR.addQuery('group', resGroup);
userGR.query();
var userList = [];
while (userGR.next()) {
var userId = userGR.user.sys_id;
var userRoleGR = new GlideRecord('sys_user_has_role');
userRoleGR.addQuery('user', userId);
userRoleGR.addQuery('role.name', "resolver_group_manager");
userRoleGR.query();
if (userRoleGR.next()) {
userList.push(userId.toString());
}
}
return "sys_idIN"+userList.join(','));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2024 04:26 AM
I wasn't sure if you can call the out of box Business Rule name getRoledUsers from within your Script Include. Is the Script Include in the Global scope? You can try copying the script from this Business Rule and incorporating it into your script, or just use my proposed Reference qualifier as an alternative since calling the Business Rule from a qualifier is how this was designed to work.