SetupAttributeAccessHandler is not called when the entity is new

Hello Team,

I am wondering whether this the expected behavior of the SetupAttributeAccessHandler not to be called when the entity is new or i am missing something. i have the following code to demonstrate my issue:

public class LookupValueAttributeAccessHandler implements SetupAttributeAccessHandler<LookupValue> {
    public void setupAccess(SetupAttributeAccessEvent<LookupValue> event) {

    public boolean supports(Class clazz) {
        return LookupValue.class.isAssignableFrom(clazz);

when the entity is created the sector attribute can be modified, but when the entity is edited the sector attribute is readOnly.
if this is the expected behavior for the SetupAttributeAccessHandler, where is the right place to put readOnly rules that gets applied whether the entity is new or edited.

Hi Tarek,

Yes this is the correct behavior - SetupAttributeAccessHandler is called only on entity loading or when you explicitly call attributeAccessSupport.applyAttributeAccess() in a screen. In both cases it is an entity already stored in the database.
Could you explain the use case when you need this for a new instance?

Hi Konstantin,

I have a detail called LookupValue that has a field called sector, i have a master called Lookup that controls whether the lookup values are allowed to be linked to a sector or not, the control in the lookup is done via a boolean attribute. i was trying to find a unified way where i can control the read-only property for any entity based on:

  • either some logic regardless it’s a new entity or not like this particular case.
  • or based on the state of the entity, if it’s being edited some attributes can’t be modified, which i already achieved using SetupAttributeAccessHandler for other entities in my model.

I understand your situation, but at the moment I cannot offer anything except obvious delegating logic from UI screens and SetupAttributeAccessHandlers to some common bean.

We’ll try to design a better way in the future: I have created an issue.

1 Like