How to save data from dialog throught macro editor?

Hi,
this is my senario
user open macro
marco editor opened
user select a choice from macro editor and click save
new dialog opened and user enter some text (need to save that on macro page)
user close second dialog
text are saved on macro page

to open the dialog from dialog marco, i do

AP.dialog.getButton("submit").bind(function () {
    AP.dialog.create({
        key: 'dialog-2',
        width: '100%',
        height: '100%',
        chrome: false
    });
}

new dialog opened but don’t know how to save, so

how to save data from second dialog in this case and show it on macro page?
how to close marco editor and open new editor?

thanks

In a dialog opener page:

AP.dialog.create({
        key: 'dialog-2',
        width: '100%',
        height: '100%',
        chrome: false
    })
.on("close", (dataFromTheDialogCloseEvent) => //bla bla);

Inside the dialog

AP.dialog.close("data to pass for parent view")

@Alexandr thank you!
you saved me :slight_smile: