- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 11:16 AM
Hi,
I have created the UI action called "Required Action" on RITM table. now i want to make it this UI action available for only if logged In User is member of the RITM associated SC Task assignment group. I have tried by using below UI action Condition and Script Include but it is not working as expected. Please let me know, how to archive this by using UI action condition.
Please Find the below script for reference.
UI Action Condition:
new CheckUserGroup().isUserInRitmGroup(current.sys_id)
Script Include:
Thanks InAdvanced!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 11:25 AM
You do not need to create a client UI action. You can just provide the RITM record in the parameters of the function.
Condition:
new CheckUserGroup().isUserInRitmGroup(current);
Script:
var CheckUserGroup = Class.create();
CheckUserGroup.prototype = {
initialize: function() {
},
isUserInRitmGroup: function(ritmGr) {
var ritmId = ritmGr.getUniqueValue();
var taskGr = new GlideRecord("sc_task");
taskGr.addQuery('parent', ritmId);
taskGr.query();
while (taskGr.next()) {
var userId = gs.getUserID();
var groupId = taskGr.getValue("assignment_group");
var groupMemberGr = new GlideRecord('sys_user_grmember');
groupMemberGr.addQuery('user', userId);
groupMemberGr.addQuery('group', taskId);
groupMemberGr.query();
if (groupMemberGr.next()) {
return true;
}
}
return false;
},
type: 'CheckUserGroup'
};
Let me know if this works.
Kind regards,
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 11:25 AM
You do not need to create a client UI action. You can just provide the RITM record in the parameters of the function.
Condition:
new CheckUserGroup().isUserInRitmGroup(current);
Script:
var CheckUserGroup = Class.create();
CheckUserGroup.prototype = {
initialize: function() {
},
isUserInRitmGroup: function(ritmGr) {
var ritmId = ritmGr.getUniqueValue();
var taskGr = new GlideRecord("sc_task");
taskGr.addQuery('parent', ritmId);
taskGr.query();
while (taskGr.next()) {
var userId = gs.getUserID();
var groupId = taskGr.getValue("assignment_group");
var groupMemberGr = new GlideRecord('sys_user_grmember');
groupMemberGr.addQuery('user', userId);
groupMemberGr.addQuery('group', taskId);
groupMemberGr.query();
if (groupMemberGr.next()) {
return true;
}
}
return false;
},
type: 'CheckUserGroup'
};
Let me know if this works.
Kind regards,
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 12:12 AM