How to make lookup field READONLY after INSERT

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
soewandi
Veteran Member
Posts: 34
Joined: 2019-11-20 14:00

How to make lookup field READONLY after INSERT

Post by soewandi » 2024-09-29 15:12

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

soewandi
Veteran Member
Posts: 34
Joined: 2019-11-20 14:00

Re: How to make lookup field READONLY after INSERT

Post by soewandi » 2024-09-30 04:11

Sorry, I found the simple way :) . It can be achieve by setting "Hide in detail view"

ppfoong
Veteran Member
Posts: 52
Joined: 2021-07-13 16:46

Re: How to make lookup field READONLY after INSERT

Post by ppfoong » 2024-10-01 04:40

Since you mentioned you have AG JS Helper, you can take a look at this info:

https://www.appgini.de/docs/Javascript- ... nable.html

ppfoong
Veteran Member
Posts: 52
Joined: 2021-07-13 16:46

Re: How to make lookup field READONLY after INSERT

Post by ppfoong » 2024-10-01 04:45

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.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1205
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: How to make lookup field READONLY after INSERT

Post by onoehring » 2024-10-02 08:37

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

Post Reply