jeudi 25 novembre 2010

How to create a dialog in a class and then returning the report in Dynamics AX

We can create the dialog usig the overrided method 'dialog' in the report and we can use separately a class that create the dialog , get the right values and then call the report.

In this class, we have theses methods:
 We must use :
Dialog: where we define the variables to use: 

Object dialog()
{
    DialogRunbase dialog = super();
    ;
    dialog.caption("@PAY5567");
    filetxt = dialog.addFieldValue(typeid(NoYes),rangePaytypeNum);
    filetxt.label("@Pay5325");
    Path  = dialog.addFieldValue(typeId(FileNameSave),rangePaytypeNum);
    return dialog;
}


We must use :
lastValueElementName: to call the appropriate report :
 
 identifiername lastValueElementName()
{
    return ReportStr(PayrollTransfer);
}



We must finally use :
main : to initialize and run the class for example : 

static void main(Args args)
{
    PayrolltransferReport                 payrolltransferReport ;
    ;
    payrolltransferReport  = new PayrolltransferReport ();

    if (payrolltransferReport .prompt() )
    {
        payrolltransferReport.run();
    }
}


We can use  
GetFromDialog: where we want to return the values entered: 

For example : 
public NoYes getFromDialog()
{
    ;
    showHolidaySection = NoYesCombo1.value();
    ChoosePrinter = NoYesCombo.value();
    return  super();
}

We can use 
Run : If we have some infologs or messages to display while filling in the dialog For example 

public void run()
{
    textbuffer  bufferyear;
    String30    buffertrimester;
    ;
    okcancel   = false;

    if(filetxt.value()==1)
    {
        if (path.value()!="" )
        {
            this.f_txt(path.value());
        //Le fichier text est crée
            Box::info("@Pay5323","info","...");
        }
        //L'emplacement est invalide !
        else
        {
            Box::info("@Pay5324","info","....");
            okcancel = true;
        }
    }

    else
    {
            okcancel = false;
    }

   // if(!okcancel)

    super();
}

Happy Daxing!

Aucun commentaire:

Enregistrer un commentaire