All fields on incident should be readonly once the state is changed to reolved

Pratiksha KC
Tera Guru

When state is Resolved, it should make all the fields read only on Incident form.

I tried UI Policy - but it is making only few fields read-only. 

function onCondition() {
var fields = g_form.getEditableFields();  
    for (var x = 0; x < fields.length; x++) {  
        g_form.setReadOnly(fields[x], true);  
    }  
}
Also thought of ACL. but not sure about the role. 
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@Pratiksha KC 

I will recommend to use ACL approach and not client script. If you use client script users can still edit from list.

OOTB there is 1 Table.None WRITE ACL which allows updating only when State [IS NOT] Closed

-> https://instanceName.service-now.com/nav_to.do?uri=sys_security_acl.do?sys_id=66ec26370a0a0b0100a67b597d415b84

Update the condition as this

State [IS NOT ONE OF] Closed, Resolved

AnkurBawiskar_0-1767778473205.png

-> There is 1 other ACL which allows updating INC if you opened it or you are caller

https://instanceName.service-now.com/nav_to.do?uri=sys_security_acl.do?sys_id=66ecaf4d0a0a0b010029ce5027a8d56f

Update condition as this

Incident State [IS NOT ONE OF] Closed, Resolved

AnkurBawiskar_1-1767778592323.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

4 REPLIES 4

shaik23
Tera Expert

@Pratiksha KC Hi tried onload script?

function onLoad() {
if (g_form.getValue('state') == '6') { 
readOnly();
}
}

function readOnly() {
var fields = g_form.getEditableFields();
for (var i = 0; i < fields.length; i++) {
g_form.setReadOnly(fields[i], true);
}
}

Chaitanya ILCR
Mega Patron

Hi @Pratiksha KC ,

create an ACL like this

 

ChaitanyaILCR_0-1767778324653.png

since no one is supposed to edit don't give any roles 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Adrian Ubeda
Mega Sage

Hello @Pratiksha KC , 

 

You should cover this using UI Policy is the proper and correct way, I don't understand why only 'few' fields are read only, add all you need (fields) as a Policy action. 

You can achieve this using client script onChange on state field, but I strongly recommend use UI Policy

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

Ankur Bawiskar
Tera Patron

@Pratiksha KC 

I will recommend to use ACL approach and not client script. If you use client script users can still edit from list.

OOTB there is 1 Table.None WRITE ACL which allows updating only when State [IS NOT] Closed

-> https://instanceName.service-now.com/nav_to.do?uri=sys_security_acl.do?sys_id=66ec26370a0a0b0100a67b597d415b84

Update the condition as this

State [IS NOT ONE OF] Closed, Resolved

AnkurBawiskar_0-1767778473205.png

-> There is 1 other ACL which allows updating INC if you opened it or you are caller

https://instanceName.service-now.com/nav_to.do?uri=sys_security_acl.do?sys_id=66ecaf4d0a0a0b010029ce5027a8d56f

Update condition as this

Incident State [IS NOT ONE OF] Closed, Resolved

AnkurBawiskar_1-1767778592323.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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