ARIS Community - We Love BPM

Escape user dialog

hreidemeister's picture
by Holger Reidemeister in Reports & Macros posted on 2017-02-14

Hallo all together,

my problem is the escape from a user dialog in a report.

I've created a dialog window in my report similar to the example on the help side "Report class DialogObject". I've adapted it to my report as a single side dialog and it works, excepted one feature. I can click "OK" and the dialog ends and I can click "Escape" and it also ends.

But how can I read in my report, which button has finalized the dialog?

Therefore I could'nt find any notes in the help side.

I wold be happy if is somebody who can help me.

Many thanks.

1705 Views
0 Likes
9 Comments
There are no attachments
Robert Goldenbaum posted on 2017-02-14

Hi,

well, normally you can catch that someone has pressed a button like this:

        iDialogTemplate1.PushButton(15, 322, 80, 20, "Standard","buttonStandard");
...

    this.buttonStandard_pressed = function(){
        INIT_ReadStandardOptions();
        this.setBasicValues();
        this.enableStandard();
        
        return true;
    }
 

So you should be able to set a global variable and then end the dialog...

BR Robert

 

Holger Reidemeister posted on 2017-02-14

Hallo Robert,

many thanks for your answer. In the described way you generate a new button. But the dialog has still two buttons: One for "OK" and one for "Cancel". Do you know the id of one of these buttons? Then I can set a global variable as you mentioned.

Robert Goldenbaum posted on 2017-02-14

Well, somewhere there was an ID once for those two buttons, but they never (!) worked. You could also not remove them etc. - could be called a bug, could be called a feature :-)

Robert Goldenbaum posted on 2017-02-14

Ah, but you just want to know if cancel was pressed ?

Robert Goldenbaum posted on 2017-02-14

    var lResult = Dialogs.showDialog(new DIA_configSubDialog(), Constants.DIALOG_TYPE_WIZARD , "Transfer Model Changes");
    if (lResult != -1)
        return false;
 

...

 

    this.onClose = function(pageNumber, bOk){
        if (bOk){
            this.lResult = -1;
        }
    }
 

    this.getResult = function(){
        
        if (this.lResult == -1){
...

Robert Goldenbaum posted on 2017-02-14

        return this.lResult;
 

Holger Reidemeister posted on 2017-02-15

Hallo Robert,

thanks for your effort and your ideas. But (sorry) it does not work. I guess the reason is the this.onClose function would never be called (I sat a breakpoint in this function). Doesn't matter if I finish with "OK" or with "Cancel". So there is no chance to set this.lResult.

Could be a bug?

Robert Goldenbaum posted on 2017-02-15

Hi Holger,

well, you cannot debug a dialog - breakpoints don't work there...   But it definitely works like this - so you can distinguish between the standard ok and the standard cancel button. But I think my code was not enough. Try this one:

main(){

    if(DIA_configDialog()){
            ....
    }
}

function DIA_configDialog(){
    
    // set selection to global options
    var lResult = Dialogs.showDialog(new DIA_configSubDialog(), Constants.DIALOG_TYPE_WIZARD, "Name of the script");
    if (lResult != -1)
        return false;
    
    return true;
}
 

function DIA_configSubDialog(){
    var sPassword = "";    
    var lResult = 0;
    
    // returns DialogTemplate[] (see help) or the dialog XML ID
    this.getPages = function(){
        var iDialogTemplate1 = Dialogs.createNewDialogTemplate(0, 0, 0, 0, "Script options");
        iDialogTemplate1.GroupBox(15, 10, 420, 60, "  " + "Password secured" + "  ");
        iDialogTemplate1.Text(30, 35, 200, 15, "Please insert script password:");
        iDialogTemplate1.TextBox(230, 35, 160, 15, "password", -1)
        iDialogTemplate1.OKButton();
        iDialogTemplate1.CancelButton();
        return [iDialogTemplate1];
    }
    
    this.isInValidState = function(pageNumber){
        return true;
    }
    
    this.canFinish = function(pageNumber){
        return true;
    }
    
    this.canChangePage = function(pageNumber){
        return true;
    }
    
    this.onClose = function(pageNumber, bOk){
        if (bOk){
            this.lResult = -1;
        }
    }
    
    this.getResult = function(){
        
        if (this.lResult == -1){
            sPassword = this.dialog.getPage(0).getDialogElement("password").getText();
            if(sPassword == "" || !sPassword.equals("I like IDS")){
                Dialogs.MsgBox("Wrong password, report execution canceled.", Constants.MSGBOX_ICON_INFORMATION, "Password secured");
                Context.setScriptError(Constants.ERR_CANCEL);
                return false;
            }
        }
        return this.lResult;
    }
}
 

Holger Reidemeister posted on 2017-02-16

Hallo Robert,

so it works. Many many thanks for your help.