Tuesday, 15 December 2015

How to Get Selected Customer all Transaction using Morphx Reports in Ax 2012


  • Design a Form as Below 

  • Here I Added a Button Named as Print 
             I have Overrided Clicked Method
              void clicked()
              {

                    Args args = new args();
                    ReportRun reportRun;
                    ;

                    args.parm(Customers.valueStr());       //Customers indicates Lookup name
                    args.name(reportstr("Custtrans"));     //Custtrans indicates Morphx report name
                    reportRun = classFactory.reportRunClass(args);
                    reportRun.init();
                    reportrun.run();
                   //reportRun.wait();
                   //args.parmObject( args );
                   super();
                }
  • Added a StringEdit control Named as Customers               //Auto declaration Yes
            I have overrided Lookup Method
          public void lookup()
         {
                Query query = new Query();
                QueryBuildDataSource queryBuildDataSource;
                QueryBuildRange queryBuildRange;
                SysTableLookup sysTableLookup =               SysTableLookup::newParameters(tableNum(custTable), this);
                sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
                sysTableLookup.performFormLookup();
               //super();
           }

  • Design a Morphx Report



     Under Report override Init Method
     public void init()

    {
    Query query1 = new Query();
    QueryBuildDataSource queryBuildDataSource;
    QueryBuildRange queryBuildRange;
    str var;
    ;

    var = element.args().parm();

    try
    {
      if(element.args().parm())
      {
           query1.addDataSource(tablenum(CustTrans)).addRange(fieldnum(CustTrans, AccountNum)).value(queryValue(element.args().parm()));
           this.query(query1);
           this.query().userUpdate(false);
           this.query().interactive(false);

           super();

      }
     }
     catch(exception::Error)
     {
       info("Error in init method");
     }
}
  • Now Open Form and Select Customer and Click on Print 



  • Finally Report appears for Selected Customer (Here I selected US-013)





No comments:

Post a Comment