How to make incident editable only for member of assignment group?

akshay parekar1
Tera Contributor

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!!

2 ACCEPTED SOLUTIONS

Samaksh Wani
Giga Sage
Giga Sage

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

View solution in original post

Manmohan K
Tera Sage

Hi @akshay parekar1 

 

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

 

  1. Create a Before -Query Business rule on 'Incident' table
  2. 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);

 

View solution in original post

4 REPLIES 4

Harshal Aditya
Mega Sage
Mega Sage

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

Samaksh Wani
Giga Sage
Giga Sage

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

@Samaksh Wani 

@akshay parekar1 

 

How this answer is correct ?🤔

 

We can not use gs object in onload client script

Manmohan K
Tera Sage

Hi @akshay parekar1 

 

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

 

  1. Create a Before -Query Business rule on 'Incident' table
  2. 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);