addGeneratedColumn Access control

Hi,

Is it possible to control addGeneratedColumn similar like Menu or screen access.

I had used addGeneratedColumn on browse screen and added buttons in that column i want to provide access to users who will have access to that is that possible.

Currently i am provinding access on basis of role.

Hello!

I think you can use specific permissions, see Resource Roles :: Jmix Documentation.

Create specific permission and check it before adding generated column:

@Autowired
protected AccessManager accessManager;

@Subscribe
public void onInit(InitEvent event) {
    EntityGeneratedColumnContext context = new EntityGeneratedColumnContext();
    accessManager.applyRegisteredConstraints(context);

    if (context.isPermitted()) {
        ordersTable.addGeneratedColumn("someColumn", entity -> {
            // do smth
        });
    }
}

If user’s ResourceRole contains this permission, column will be added.

1 Like

Hi,

I created an interface and added specificpolicy but values are only visible to that role in resource role.
I want to create an custom access which any role can use similiar to like ui.login specific policy and the same i want to check on controller that if that role has that custom created access right he can hide or disable button or add any other logic.


@ResourceRole(
        name = "Customers: non-confidential info only, cannot delete",
        code = "customer-nonconfidential-access")
public interface CustomerNonConfidentialAccessRole {
@SpecificPolicy(
        resources = {"customer.notify"})
void customer();
}