Filter User Browser by Role

Hello,
I have a simple picker for users
I need to pick users from only 2 roles when the user browse screen pops out.
I cant modify the Cuba user screen since its a system page. Is creating a separate screen what I need with a public function to modify the filter?

When loading the edit page I’m trying to modify the lookup action but haven’t had any success.
Could anyone please help?

Hi.

You can create a separate screen for User, in CollectionLoader specify JPQL query that selects users with only necessary roles.

After that, you can customize the standard actions behavior by subscribing to the ActionPerformedEvent and providing your own implementation. You can use a specific lookup screen as follows:

@Inject
private ScreenBuilders screenBuilders;
@Inject
private PickerField<Color> pickerField;

@Subscribe("pickerField.lookup")
protected void onPickerFieldLookupActionPerformed(Action.ActionPerformedEvent event) {
        screenBuilders.lookup(pickerField)
                 .withScreenClass(CustomUserBrowser.class)
                 .build()
                 .show();
}

Regards,
Natalia

tried it… it works !!! Balshoi Spasibo !!!

1 Like