How to set related list to read-only based on state field value

rafaelvd
Kilo Explorer

Hi,

I had received a request from a client as to set related lists to read-only according to State field value. I planned to just set the ACL for this to work.

I've already asked hi.service-now for assistance, but this requires customization so they advised I post here for help..

But I have a problem on how do I do this if the related list is not exclusive to Change records such as Problems and Incident lists. Is there a way to do this or at least just disable the list editing only when the change record is loaded without affecting any users editing via the Incident table? Also as far as the buttons go, I think it can be hidden via script right?

How would I also apply this if the related list is an m2m list?

12 REPLIES 12

Anurag Tripathi
Mega Patron
Mega Patron

Hi,



Let me state what i understood from the question


You are on Change Request form and you have related lists like problem and incident on your form.


Now what you want is, if the change request's state is Closed(assuming) then the incident and problem related lists should become non editable.




If that's the problem then you can achieve this through ACL


ACL Details(assuming that problem related list is attached to CR through the parent field, and the state value is closed,3)



Type - record


Operation - list edit


Name -> problem *


Script->


if(current.parent!='' && current.parent.getDisplayValue().indexOf('CHG') >-1)


{


if(current.parent.state==3)


{


answer=false;


}


}


-Anurag

Hi Anurag,



There is a built in field in Incidents and Problems named "Change Request".



Given your solution, would that have any impact on the problem table if i were to view its list?



Also, how would I apply the solution if the related list was m2m?


Yes, it will have impact if you view problem table through List view. So i see now that this is not the best solution at hand.


For M2M it will work in the same way, ACL would go on the M2M table and field's name would change, some dot walking may be.


-Anurag

Yup. This is why hi.service-now suggested that I ask it here in community.



I don't know if this has been done before, but it certainly does require some customization.