Bulk Editor - Filter Selectable Entity options by DataContainer

I am wondering whether or not in the bulk editor you can filter the entities for a lookup type field. Or add a lookup field that is based on a data container?

e.g. I have a class

public class MyEntity {      
    @OneToMany
    protected List<MyOtherEntity> subEntities;
    
     @OneToMany
    protected List<SubOption> subOptions;

}

public class MyOtherEntity {      

     @ManyToOne
    protected MyEntity myEntity;

    @ManyToOne
    protected SubOption subOption;
}

I have a screen for MyEntity with a table for MyOtherEntity showing all the rows relating to MyEntity.
I want to be able to bulk edit that table (MyOtherEntity) the column “subOption” where the only subOptions selectable are contained in the MyEntity subOptionsDc.

If that makes sense…

Like is it possible to do something like

bulkEditor.getProperty(subOption).setQuery(select e from demo_SubOption e where e.myEntity = :container_myEntityDc)

or like can be done with the datagrid:

  @Subscribe
public void onInit(InitEvent event) {
    myOtherEntityDataGrid.getColumnNN("subOption").setEditFieldGenerator(subOptionEditorFieldGenerationContext ->  {
        LookupField<SubOption > lookupField = uiComponents.create(LookupField.NAME);
        lookupField.setOptionsList(subOptionsDc.getItems());
        return lookupField;
    });
}

Hello,

there is no such API in BulkEdit action. But you can try to get the field from opened screen. For instance, using BulkEditors you can configure a bulk editor and get a screen instance:

@Inject
private BulkEditors bulkEditors;

@Subscribe("orderLinesTable.bulk")
public void onOrdersTableBulk(Action.ActionPerformedEvent event) {
    BulkEditorWindow bulkEditorWindow = bulkEditors
            .builder(metadata.getClassNN(OrderLine.class), orderLinesTable.getSelected(), this)
            .create();
    bulkEditorWindow.show();
}

Then in the debug mode you can find component you need. Note, that BulkEditorWindow has its own field factory and for the entity type will be created PickerField.

ScrollBoxLayout container = (ScrollBoxLayout) bulkEditorWindow.getWindow().getComponent("fieldsScrollBox");
CssLayout fieldsLayout = (CssLayout) container.getComponentNN(0);

VBoxLayout column = (VBoxLayout) fieldsLayout.getComponentNN(1);
CssLayout row = (CssLayout) column.getComponentNN(0);
PickerField pickerField = (PickerField) row.getComponentNN(1); // 0 - caption, 1 - field

In the PickerField we can set Lookup Screen that should be opened and send some params:

PickerField.LookupAction lookupAction = (PickerField.LookupAction) pickerField.getAction(PickerField.LookupAction.NAME);
lookupAction.setLookupScreen("customOrderLookup");
lookupAction.setLookupScreenParams(new HashMap<>());

Or remove it and add your action.