UI Policies-Make field read only in review state

Kajal2
Kilo Contributor

UI Policies-Make field read only in review state

Hi,

I am writing a script for making the fields read only for a particular state(Review). I want the member of a specific group(member of IT_GRC(sys_id+76c540dbdb8cd090c7d99c18db961941)) only should be able to edit the form, what should I put in the script!!

function onCondition() {
var currentUser = g_user.userID; //stores the logged in user in currentUser


if (currentUser !=What shoul I put here?) {
var fields = g_form.getEditableFields();


for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);

 

}
}
}

If any other changes required in the script, please let me know

 

Regards,

Kajal

1 ACCEPTED SOLUTION

Hi Kajal,

It is happening due to OOB UI policy with short description - "PE Reason read only and mandatory condition". You can update it accordingly.

Let me know in case of any queries.
If you think my response is helpful for you? If yes, mark it as correct answer and close the loop so that it would help future readers as well.

Regards,
Deepankar Mathur

View solution in original post

12 REPLIES 12

Aman Kumar S
Kilo Patron

What shoul I put here --> sys_id of the user for whom you want the field to be editable

 

if (currentUser != "76c540dbdb8cd090c7d99c18db961941")

Best Regards
Aman Kumar

I don't want this for a single user.

Can I put the sys_id of the group and then all members in the group should be able to edit?

Hi Kajal,

It could be achieve via client script and ACL.

Better to create an ACL on that table. It would be Read operation. field level ACL (field which you want to edit when state == (which you want)).

 

If you are not confident regarding ACL then go with Client script. Use ReadOnly g_form method and you set your conditions based on groups.

dmathur09
Kilo Sage
Kilo Sage

Hi Kajal,

You would be required to create a display business rule.

Place the below script in your business rule

g_scratchpad.grp = gs.getUser().isMemberOf('PASS GROUP NAME HERE');

Coming to the client script

 

function onCondition() {
if (!g_scratchpad.grp)
{
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}
}

Hope this helps.

Regards,

Deepankar Mathur