check loggedin user role in ACL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 01:06 AM
I created custom role 'X' when user with 'X' role logged in he needs to have write access to incidents that are opened by user with 'X' role.
For all other incidents created by different role, those records should be read-only..
Please help me to achieve this.?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 02:11 AM - edited 04-04-2023 02:13 AM
Hi,
Try this in the script of ACL, replace the X in the script with the role you have
if(gs.hasRole('X') & gs.getUser().getUserByID(current.created_by).getRoles().toString().indexOf('X') >-1)
{
answer= true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 04:04 AM
Hi @Anurag Tripathi ,
I wrote this in write ACL incident*..but it didnt work..
as of now user can is able to edit only his own incidents(Caller=loggedin user) but he should be able to edit all incidents opened by custom role.
any other solution?
any other way ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 04:48 AM
try this, there was one & less
if(gs.hasRole('X') && gs.getUser().getUserByID(current.created_by).getRoles().toString().indexOf('X') >-1)
{
answer= true;
}
Also, use debug feature to see which ACL is returning false, you may have to modify that acl also along with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 02:11 AM
Hi @soumya17 ,
Hope you are doing well.
You can update/create OOB incident read and write ACL and use code below
var answer;
if(gs.hasRole('x')){
answer = true;
}
else
answer = false;
Please mark this response as correct or helpful if it assisted you with your question.
Regards,
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 04:02 AM
i tried this in write ACL incident*.
user can edit only his incidents but he should be able to edit all incidents opened by custom role.
Thanks