Search This Blog

Friday, June 28, 2013

Dynamics ax 2009 functional​ity on android platform. Demo VDO



Hi Guys,

I found a video link of AX Functionality :

Dynamics ax 2009 functionality on android platform. Demo video :

https://www.youtube.com/watch?v=UqBP-ZxXq2g

Courtesy :
Started by Kirtan Dave, Dynamics AX Software Developer at Systems Advisers Group

Happy Daxing...!

Thursday, June 27, 2013

Dialog field lookup method

Hi ,
  Dialog forms are extends with Runbase class or Runbasebatch class ,In this class dialog fields are
added in dialog method for these dialog fields we can write a lookup method in below manner

void Fld9_1_lookup()
 {
    Formrun fr = dialog.formRun();
    object Control = fr.controlCallingMethod();
    SysTableLookup       sysTableLookup = SysTableLookup::newParameters(tablenum(EmplTable),  dialogEmployee.fieldControl());
    Query                query = new Query();
    QueryBuildDataSource queryBuildDataSource;
    queryBuildRange         maintenancesection;
    ;
    sysTableLookup.addLookupfield(fieldnum(EmplTable, EmplId));
    SysTableLookup.addLookupMethod(identifierstr(name));
    sysTableLookup.addLookupfield(fieldnum(EmplTable, EAMMaintenanceSection));
    queryBuildDataSource = query.addDataSource(tablenum(EmplTable));
    maintenancesection = queryBuildDataSource.addRange(fieldnum(EmplTable,EAMMaintenanceSection));
    maintenancesection.value(SysQuery::valueNotEmptyString());
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}
Like this we can create a lookup for dialog fields  in dialog form

Thanks
 

Tuesday, June 11, 2013

How to send Normal AX Reports to User through Batch Process in Dynamics Ax 2009.


Hi friends,
Recently I got one requirements from my User, I.e. customer want to see ax reports in E-mail everyday once through batch process.
its just like send mail from batch process only, But we need to work on how to send normal report.

1) write the class with below methods mandatory.
         


2)Here am going to post logic for how to convert ax report to PDF and how to send the email to user only.

// Saved the reports into particular location
void SaveReport()
{
    Args args;
    ReportRun rr;
    str reportName = "OpenPurchOrderLine_Vendor";
    str myPath;
    int i;
   ;
   i = 1;
  args = new Args(reportName);
  args.caller(rr);
  rr = new reportRun(args);
    rr.query().interactive(false);
    rr.report().interactive(false);
    rr.setTarget(printMedium::File);
    rr.printJobSettings().setTarget(PrintMedium::File);
    rr.printJobSettings().preferredTarget(PrintMedium::File);
    rr.printJobSettings().format(PrintFormat::PDF);
    rr.printJobSettings().warnIfFileExists(false);
    rr.printJobSettings().suppressScalingMessage(true);
    pdfFileName = @\\AXTESTDEV1\D$\Test\test.pdf; //@ is used for server\\ServerName\drive name$\Folder
    rr.printJobSettings().fileName(pdfFileName);
    rr.init();
    rr.run();
    info("After Run in SaveReport()");
}

//Used to sending emails to particular users

void EmailCheck()
{
         //Set                     permissionSet2 = new Set(Types::Class);
         InteropPermission permission = new InteropPermission(InteropKind::ComInterop);
         ;
        CodeAccessPermission::revertAssert();
        info("After code access in EmailCheck()");
         permission.assert();
         mailer = new SysMailer();
         parameters = SysEmailParameters::find();
        if (parameters.SMTPRelayServerName)
       {
            mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
                         parameters.SMTPPortNumber,
                         parameters.SMTPUserName,
                         SysEmailParameters::password(),
                         parameters.NTLM);
             info("if");
       }
      else
      {
        mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
                             parameters.SMTPPortNumber,
                             parameters.SMTPUserName,
                             SysEmailParameters::password(),
                             parameters.NTLM);
                  info("else");
        }
        mailer.fromAddress('xyz@abc.com');
       mailer.tos().appendAddress('abc@xyz.com');
       mailer.tos().appendAddress('TEST@company.com');
      mailer.htmlBody('Find the attachment.
                         <Br>\n NOTE:This is a System Generated Email. Please do not Reply.');
      mailer.subject('Report Attached(Testing Mail)');
      info(pdfFileName);
      mailer.attachments().add("D:\\Test\\test.pdf");
       mailer.sendMail();
       CodeAccessPermission::revertAssert();
}
Next Configure this class into batch Job User Form.....
If any clarification or issues please comments to this..
Happy
Daxing...
  

Full Text Index in Dynamics AX 2012

Hi Friends,
Full text index supports to quickly query words that are embedded in the middle of a string field of a table. Well, this is a very nice enhancement to query on Database table fields for the developers who work with the latest vesion [Microsoft Dynamics AX 2012]
Good thing is we can use this Index on Memo fields and also Extended data type.
Let me explain with an example. Create a new table as shown below and add a new field of type string “Name” to it – On the field use EDT – Name. In the below example, my table Name is SR_FullTextExample.
Once you are done with your table, Go to FullTextIndex Node >> Right click and create a new FullTextIndex.
Rename it to NameFullTextIndex. Drag and drop Name field from the fields to the newly created index.
The table with index should look like below.







The following X++ Job uses a full text index that exists on a table and field that it queries.

static void FullTextExamp(Args _args)
{
    FullTextExample fullTextExample_obj;
    Query qr;
    QueryBuildDataSource qbds;
    QueryBuildRange qbr;
    QueryRun qrun;
    ;
    qr = new Query();
    qbds = qr.addDataSource(tableNum(FullTextExample));
    qbr = qbds.addRange(fieldNum(FullTextExample,Name));
    qbr.rangeType(QueryRangeType::FullText);
    qbr.value("Brahma Kumar");
    qrun = new QueryRun(qr);
    while(qrun.next())
    {
        fullTextExample_obj = qrun.get(tableNum(FullTextExample));
        info(fullTextExample_obj.Name);
    }

}
Output:


Happy
Daxing.....







Monday, June 10, 2013

How to retrieve multiple selected records from Grid using X++ in Axapta

Hi Friends,

In this post, we discuss how we can retrieve all selected(marked) records of a datasource or retrieve marked records form Grid.
For this purpose follow the steps listed below.
  1. Create a new table named "TabPet" that contains two string fields i.e. Name & ID.
  2. Create a new form and add the newly created "Student" table in the datasource node.
  3. Next create a new button on the form, set its multiselect property to "Yes" . Now override the clicked method of the button and add the following code.
Code snippet

    int             recordsCount;
    TabPet      TabpetLocal;
    super();
    
    recordsCount = TabPet _ds.recordsMarked().lastIndex();  // Total number of marked records.
    TabpetLocalTabPet_ds.getFirst(1);
    
    while (TabpetLocal)
    {
        info(TabpetLocal.Name +" " +TabpetLocal.ID);
        TabpetLocal= student_ds.getNext();
    }

Happy 
Daxing...

Friday, June 7, 2013

Convert word Documents into PDF report [using X++ in Dynamics AX 2009]

Hi Friends,
This is the way we can convert word format report into PDF in ax2009

static void dsiple_PDS(Args _args)
{
    Args args;
    ReportRun rr;
    str reportName = "ReportName";
    PurchRFQLine rfqLineTable;
    str myPath;
    str pdfFileName;
    int i;
    COM wordApplication;
    COM wordDocuments;
    COM wordDocument;
    COM wordRange;
    str a[];
    str path;
    str pdfPath;
    str finalPath;
    int length;
    int minus;
    ;
    i = 1;
    myPath = winApi::getTempPath();
    info(myPath);
    args = new Args(reportName);
    args.caller(rr);
    //rr = new reportRun(args);
    while select  rfqLineTable where rfqLineTable.RFQId == "00039237_183"
    {

       // pdfFileName = myPath + strfmt("test%1.pdf",i);
        args.record(rfqLineTable);
        rr = new reportRun(args);
        rr.query().interactive(false);
        rr.report().interactive(false);

        rr.setTarget(printMedium::File);
        rr.printJobSettings().setTarget(PrintMedium::File);
        rr.printJobSettings().preferredTarget(PrintMedium::File);
        rr.printJobSettings().format(PrintFormat::RTF);    // Now Report format is word
        rr.printJobSettings().warnIfFileExists(false);
        rr.printJobSettings().suppressScalingMessage(true);
        pdfFileName = myPath + strfmt("test%1.doc",i); // reports names are test 1,2…
        rr.printJobSettings().fileName(pdfFileName);
        a[i] =  pdfFileName; // All the Reports are stored into Array
        rr.init(); 
        rr.run();

        rr.finalize();

        wordApplication = new COM("word.application");
        wordDocuments = wordApplication.Documents();
        wordDocument = wordDocuments.Open(a[i]);//Open all the Reports
        length = strlen(pdfFileName);// Calculate the Length of the file
        minus = length - 3; //removing last 3 digits(DOC)
  
        pdfPath = strdel(pdfFileName,minus,4);//Delete  from file
        finalPath = pdfPath + ".pdf"; //Adding 3 digits to file path

         wordDocument.ExportAsFixedFormat(finalPath, 17);
        wordDocument.close();
        wordApplication.quit();
        WinAPI::deleteFile(pdfFileName);
        i++;
    }

 }
Happy
Daxing..

Tuesday, June 4, 2013

Open the Listpage form from another form by passing parameter in axapta 2012

In axapta 2012 all the common forms are listpage forms , In list page form we can't override any method so any validation can be done through ListpageInteraction Class .
My intention is open the Listpage form from another form, so for that  we need to change the code in InitializeQuery  method of ListpageInteraction class.
1) Override the clicked method of menuitembutton of Calling form
ex:
FormRun formRun;

Args args = New Args();
super()
args.name(EAMWorkRequestListPage);
args.parmEnum(EAMWorkstatus::WaitingForAuthorization);
formRun = ClassFactory.formRunclass(args);
formRun.init();
formRun.run();
formRun.wait()
 
2) Based on passing enumvalue the Listpage will be filtered by overriding the InitializeQuery method of ListpageInteraction class.
 
if(this.listPage().listPageArgs() && this.listPage().listPageArgs().enumParameter())
    {
        status = this.listPage().listPageArgs().enumParameter();
        qbds = _query.dataSourceTable(tableNum(EAMWorkRequest));
        qbds.addRange(fieldNum(EAMWorkRequest,Status)).value(queryValue(status));
    }
Also we can refer the existing classes like ProdTableListPageInteraction\initializeQuery