Check and change tenantId value before commit

Hi,
is it possible to check and change tenantId value before commit ?
Is it possible use class HasTenantAdditionalCriteriaProvider for this purposes ?

Thanks a lot
mk

Could you explain what is your goal? Do you want to check/change tenantId when saving a tenant-specific entity? Why?

I want to remove spaces and the special characters from tenantId before save, because we use tenantId as identifier across the multiple systems.
Thanks

So you mean you need to check a new tenant id when it is created in Administration → Tenants screen?

Yes. Exactly.

Then you can extend the tenant edit screen in your project and add the required logic:

  • In Studio, click “New → Screen” in Jmix tool window
  • In “Create Jmix Screen” wizard, select “Override an existing screen” template
  • On the next step, select select the tenant edit screen of the framework, and “Extend layout of existing screen”:
    image

In the created screen you can add a validation or processing like this:

@UiController("mten_Tenant.edit")
@UiDescriptor("ext-tenant-edit.xml")
public class ExtTenantEdit extends TenantEdit {

    @Autowired
    private TextField<String> tenantIdField;

    @Subscribe
    public void onBeforeCommitChanges(BeforeCommitChangesEvent event) {
        String tenantId = tenantIdField.getValue();
        tenantIdField.setValue(tenantId == null ? null : tenantId.replace(" ", ""));
    }
}

Your extended screen will be used instead of the framework’s one.

Hi Konstantin,
this is the perfect answer.

Thank you