Page 1 of 1
How to make lookup field READONLY after INSERT
Posted: 2024-09-29 15:12
by soewandi
I have fieldname1 as lookup field and the other are fieldname2, fieldname3. After Insert new record, I want to make fieldname1 as READONLY field. I hope someone could help me. As I know it is difficult to achieve that, even though I have used AG JS Helper. Many thanks.
My regards,
Soewandi
Re: How to make lookup field READONLY after INSERT
Posted: 2024-09-30 04:11
by soewandi
Sorry, I found the simple way

. It can be achieve by setting "Hide in detail view"
Re: How to make lookup field READONLY after INSERT
Posted: 2024-10-01 04:40
by ppfoong
Since you mentioned you have AG JS Helper, you can take a look at this info:
https://www.appgini.de/docs/Javascript- ... nable.html
Re: How to make lookup field READONLY after INSERT
Posted: 2024-10-01 04:45
by ppfoong
You can use JS to check for field's string length > 0 (not empty value) as a condition to disable it (set it as readonly) or hide it.
Re: How to make lookup field READONLY after INSERT
Posted: 2024-10-02 08:37
by onoehring
Hi,
I think hiding or using JS is not an option to really protect a field from being changed.
Thus I suggest you use hooks:
before_update -> read the field that should be readonly form the database, save it's value ti a variable.
Change the data[yourReadOnlyField] value to the value (variable) you just read from the DB.
This should make sure, the field can not be changed by the user. Note: If another user has worked on the same record, the value of the read only field in the DB may be different than the value shown on screen. To prevent concurrent changes, see the link in my footer.
Olaf