- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 05:23 PM
Hello Everyone,
I have an interesting requirement where end users are not allowed to rename/delete attachment in portal. End user having both scenario which they have snc_internal or no role to user. And for user who don't have any role have solution like !gs.hasRole() == true.
My question is how to we find the user who have exactly snc_internal role?
can some one help me on this. @Ankur Bawiskar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 07:46 PM
HI @SNOW44 ,
I trust you are doing great.
PLease find the below solution for the same.
// Check if the current user has the snc_internal role
function hasSNCInternalRole() {
var hasRole = false;
var user = gs.getUser();
var roles = user.getRoles();
for (var i = 0; i < roles.size(); i++) {
if (roles.get(i) == 'snc_internal' && roles.size() == 1) {
hasRole = true;
break;
}
}
return hasRole;
}
// Example usage
if (hasSNCInternalRole()) {
// User has only the snc_internal role
gs.info("User has exactly the snc_internal role.");
} else {
// User does not have exactly the snc_internal role
gs.info("User does not have exactly the snc_internal role.");
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 05:31 PM - edited 03-03-2024 05:32 PM
Hi @SNOW44 you can use gs.hasRole('snc_internal'). This will return true if loggedin user have snc_internal role,
Alternatively you use delete operation ACL instead of Business rule.
in ACL just give role snc_internal and advance script answer = false; // this will not allow them to delete attachment
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 05:34 PM
Hi Harish,
When I try gs.hasRole('snc_internal') it return true for both ITIL user and user having(snc_internal) users.
ACL is not working in portal side, I already given a try.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 05:41 PM
Hi @SNOW44 the use gs.hasRoleExactly('snc_internal');
if that doesnt work, use the below method
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 05:45 PM
Thanks harish, will check and comeback!