How to make 14 Fields editable only when state is 'Monitor' & User is part of 'XYZ' group

Obito
Tera Expert

Hi all,

I have to work on below requirement.

"How to make 14 Fields editable only when state is 'Monitor' & User is part of 'XYZ' group" 

But what should be my approach here. If I go with ACL I will have to write ACL for each field. OR Should I go with Client script to achieve the same. What is a best practice here?

 

Thanks.

3 REPLIES 3

Valmik Patil1
Kilo Sage

Hello @Obito ,

 

Client script would be a good option in this case.

but you need to use GlideAjax in this case to check if user is part of group or not.

refer below thread for GlideAjax example.

Link

Then simply you set the fields to editable.

If you want to set all the fields to editable

then refer below script

 

var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
    g_form.setReadOnly(fields[x], false); // will make field to editable
}

You can script some fields by adding condition.

 

var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
if(fields[i] ! = "<field_name>"){// will skip the fields which you add in if condition
    g_form.setReadOnly(fields[x], false); // will make field to editable
}
}

 

 

 

 

 

Thanks,

Valmik Patil

newhand
Mega Sage

@Obito 
hi.

Using a UI policy is the suggested approach.

However, the condition part is not strong enough to achieve 'User is part of the XYZ group'.

You can have a try to put the condition in the [Execute if true] script."

 

Please mark my answer as correct and helpful based on Impact.

Dee S
Giga Guru
 
 
 
 
 
 
 
 
 
 
 
try below:
if(g_user.hasRole('your_role')){
        if(g_form.getValue('state')==6){ //add value of field
        g_form.setReadOnly('field_name1',false);
g_form.setReadOnly('field_name2',false); //add like these for other fields
        }
    }
 
Please mark my answer helpful and correct based on impact