I want to make fields read only in change request and make editable by some specific groups

vivek11
Tera Contributor

we want to make description and short description read only in change request form and make editable by only some of the groups when change moves to Implement state.

What is the best way to implement it ?

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @vivek11 

 

Since you want to make it editable for only a few groups under specific conditions, you can use an ACL. However, I wouldn’t recommend it for this requirement. It’s better to either make it editable for everyone or for no one. If you want it to be editable for all, using a UI Policy is the best approach; otherwise, use an ACL or Before BR as well.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Dr Atul G- LNG
Tera Patron
Tera Patron

https://www.servicenow.com/community/developer-forum/how-to-set-field-should-be-editable-to-specific...

 

@vivek11 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@vivek11 

you can use field level WRITE ACL

Something like this, add for both the fields

answer = gs.getUser().isMemberOf('Group ABC');

AnkurBawiskar_0-1742800645113.png

 

OR

You can use Display business rule and onLoad client script

Display Business rule:

(function executeRule(current, previous /*null when async*/ ) {
    if (current.state.toString() == '-1' && gs.getUser().isMemberOf('Group ABC')) {
        g_scratchpad.canEdit = 'true';
    } else {
        g_scratchpad.canEdit = 'false';
    }
})(current, previous);

onLoad client script:

function onLoad() {
    // Check the g_scratchpad variable set by the Display Business Rule
    if (g_scratchpad.canEdit == 'false') {
        // Make the Description and Short Description fields read-only
        g_form.setReadOnly('description', true);
        g_form.setReadOnly('short_description', true);
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Medi C
Giga Sage

Hi @vivek11,

 

Best way to achieve your requirements would be Write ACLs for both short description and description. You can provide a script as follow:

answer = gs.getUser().isMemberOf('YOUR_GROUP_SYS_ID/GROUP_NAME');

 


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.