- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 04:19 AM
Hi,
I have a requirement where i want to make all fields on incident record to be editable only if
Logged in user is member of assignment group for that incident.
If he's not, then all fields should be read only
what is the best approach for the same?
Thanks in advance!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 04:29 AM
Hello @akshay parekar1
You can write a OnLoad() Client Script on table :-
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
if(!gs.getUser.isMemberOf('sys_id_of_assignment_group')){
g_form.setReadOnly(fields[x], true);
}
}
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 04:31 AM
Though this can be achieved using read ACLs, but it may force restricted users to get access through other read ACLs or OOB readACLs on that table.
Since it is not suggested to disable other ACLs, we can restrict incidents of specific group from visibility via before-query business rule
- Create a Before -Query Business rule on 'Incident' table
- In the Advanced tab, set the condition as:
!gs.getUser().isMemberOf('<group name to be restricted for other users>')
In script add below code -
(function executeRule(current, previous /*null when async*/ ) {
var grp = current.addNullQuery('assignment_group').addOrCondition('assignment_group','!=','<sys_id of the group to be restricted for other users>');
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 04:25 AM
Hi @akshay parekar1 ,
Hope you are doing well
Please try ACLs to achieve your requirements.
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
07-17-2023 04:29 AM
Hello @akshay parekar1
You can write a OnLoad() Client Script on table :-
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
if(!gs.getUser.isMemberOf('sys_id_of_assignment_group')){
g_form.setReadOnly(fields[x], true);
}
}
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 11:05 PM
How this answer is correct ?🤔
We can not use gs object in onload client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 04:31 AM
Though this can be achieved using read ACLs, but it may force restricted users to get access through other read ACLs or OOB readACLs on that table.
Since it is not suggested to disable other ACLs, we can restrict incidents of specific group from visibility via before-query business rule
- Create a Before -Query Business rule on 'Incident' table
- In the Advanced tab, set the condition as:
!gs.getUser().isMemberOf('<group name to be restricted for other users>')
In script add below code -
(function executeRule(current, previous /*null when async*/ ) {
var grp = current.addNullQuery('assignment_group').addOrCondition('assignment_group','!=','<sys_id of the group to be restricted for other users>');
})(current, previous);