Get record inserted with screenbluider

good morning everybody,
using Jmix 1.5.4, in a certain screen, I need to insert a record into another entity,
this record inserted, I’m trying to get the same, so that it is possible to use it on the main screen.
the secondary screen is a normal entity, with a screen generated by the default, without modifications.
This secondary screen is called by the code below

        if (rpTabPreEntradaItemsTable.getSingleSelected() != null && rpTabPreEntradaItemsTable.getSingleSelected().getCodItemXml() != null) {

            TabItemFornecedorCompKey chave = dataManager.create(TabItemFornecedorCompKey.class);
            chave.setCodPessoaFornecedor(getEditedEntity().getCodPessoaFornecedor().getId());
            chave.setCodItemFornecedor(rpTabPreEntradaItemsTable.getSingleSelected().getCodItemXml());

            Screen build = screenBuilders.editor(TabItemFornecedor.class, this)
                    .newEntity()
                    .withInitializer(o -> {
                        o.setId(chave);
                        o.setCodPessoaFornecedor(getEditedEntity().getCodPessoaFornecedor());
                    })
                    .withOpenMode(OpenMode.DIALOG)
                    .build();

            build.addAfterCloseListener(afterCloseEvent -> {
                if(afterCloseEvent.closedWith(StandardOutcome.COMMIT)){
                    //obter o retorno do registro criado
                    //TabItemFornecedor itemF = ****

                    //tratarRegistroRetornado(itemF)/

                }

            });

            build.show();

        }

if you can help me

Hello,

For example:

    @Subscribe("create")
    public void onCreateClick(final Button.ClickEvent event) {
        UserEdit build = (UserEdit) screenBuilders.editor(User.class, this)
                .newEntity()
                .withOpenMode(OpenMode.DIALOG)
                .build();

        build.addAfterCloseListener(e -> {
            if (e.closedWith(StandardOutcome.COMMIT)) {
                User entity = build.getEditedEntity();
                //...
            }
        });

        build.show();
  }

Regards,
Nikita

1 Like

Thank you very much for your support.