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.
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
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){
...
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?
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;
}
}