Field not editable, but on creation


i want to have a field (artikelnummer Typ) in a entity editor only editable on creation. If it’s created, the value cannot be changed.

Is is possible?

Best regards.

Hi Laurens!

You could (ab)use the InitEntityEvent for this purpose. Forget about the event data itself, the important thing here is, that this event is only triggerd if an editor screen is opened for a new entity.

  • Make the Artikelnummer-Typ field not editable in your screen descriptor (by adding the xml property editable="false" to your field tag)
  • Inject the field into your screen controller
  • Subscribe to the InitEntityEvent
  • Within the event code, set the editable flag of your field to true

In Kotlin, your screen controller might contain code like this:

private lateinit var artikelnummerTypField: LookupField<Artikeltypen>

private fun onInitEntity(event: InitEntityEvent<Apotheke>) {
    artikelnummerTypField.isEditable = true

This way, your field is normally not editable, unless your editor is opened for a new instance.


1 Like