Search This Blog

Saturday, July 26, 2014

Code to Pass Argument Values from one form to another form

Step 1: In Form A Clicked Method 

void clicked()
{
 super();
Args args = new Args();
;
args.record(TableName);
new MenuFunction(MenuItemDisplayStr(Form B),MenuItemType::Display).run(args);
}

Step 2: In class Declaration you should create a buffer for that particular table

public class FormRun extends ObjectRun
{
Table _tablelocal;
}

Step 3: In Form B init method 

public void init()
{
super();
 _tablelocal = element.args().record();
}

So by using this _tablelocal(Buffer) you can access those values anywhere in the Form B.....


Happy Dazzles..!!



Wednesday, July 9, 2014

How to pass Control Values in Form to class in AX

Step 1:

Write the method in form level like :
public str control()
{ 
return control.Text();
}

Step 2:

Write this code in class level where we need to use this value:
if(formHasMethod(args.caller(), identifierstr(MethodName)))
{ 
strcustname = args.caller().MethodName();
}


Happy Dazzles..!!


Saturday, June 14, 2014

EDT Relations in AX 2012

Migration Tool in AX 2012 :


We have created relations on EDT level in AX 2009. In Microsoft Dynamics AX 2012, relations can no longer be created under extended data type (EDT) nodes in the Application Object Tree (AOT). Relations that are defined under EDT nodes are still effective, but in a future release they will be obsolete and deleted.

The EDT relation migration tool helps you to move relations from EDT nodes to table nodes. The EDT relation migration tool is found on the client menu, under

Tools -> Code upgrade -> EDT relation migration tool.

Refer this link for more details :
http://msdn.microsoft.com/en-us/library/gg989788.aspx


Friday, March 14, 2014

To Send Normal AX Reports in PDF Format according to System Date to Users through Batch Process in AX 2009

First we need to work on how to send normal reports to PDF.

Such That we need to create a new Class with given methods below is mandatory




Next in ReportPdf( ) we have to write logic how to save normal ax reports to pdf file.


void ReportPdf()
{
    Args args;
    ReportRun rr;
    str reportName = "ProductionDailyReport";
    str myPath;
    int i;
    TransDate td;
    str rangeDate;
    ;
    i = 1;
    td = systemDateget();
    args = new Args(reportName);
    args.caller(rr);

    rr = new reportRun(args);
    rr.query().interactive(false);
    rr.query().dataSourceTable(tablenum(ProdJournalRoute)).addRange(fieldNum(ProdJournalRoute,transDate)).value(SysQuery::value(td));
    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$\Demo\Demo.pdf";
    rr.printJobSettings().fileName(pdfFileName);

    rr.init();
    rr.run();
}

Next in EmailCheck( ) we have to write logic how to  send the reports in email to users.


void EmailCheck()
{
         //Set                     permissionSet2 = new Set(Types::Class);
         InteropPermission permission = new InteropPermission(InteropKind::ComInterop);

         ;

        CodeAccessPermission::revertAssert();
         permission.assert();
         mailer = new SysMailer();
         parameters = SysEmailParameters::find();

        if (parameters.SMTPRelayServerName)
        {
            mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
                               parameters.SMTPPortNumber,
                               parameters.SMTPUserName,
                               SysEmailParameters::password(),
                               parameters.NTLM);
        }
        else
        {
            mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
                               parameters.SMTPPortNumber,
                               parameters.SMTPUserName,
                               SysEmailParameters::password(),
                               parameters.NTLM);
        }

        mailer.fromAddress(xyz@softwarecompany.com');

        mailer.tos().appendAddress('abcd@comapny.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)');
        mailer.attachments().add("D:\\Demo\\Demo.pdf");
        mailer.sendMail();
        CodeAccessPermission::revertAssert();

}

Finally We want to configure this class into batch Job User Form...!!!


Refer this Link For the Batch Job process : 



Happy Dazzles..!!

Friday, February 14, 2014

How To Use Temporary Tables In Reports

Step 1: Take a Report and Add a Table. 
Step 2: Make sure that Table Properties set as "Temporary: YES"
(OR) In Report init method write this code 

           Tmtab.setTmp();



Step 3: Apply this code in code in the report level Fetch Method :



public boolean fetch()

{
str acc;

boolean ret;

// ret = super();
while select custTable
{
Tmtab_1.CustAccount = custTable.AccountNum;
Tmtab_1.doInsert();
this.send(Tmtab_1);
}
return true;
}



Thursday, February 13, 2014

Different Types Of Joins And Link Types With example


Considering two Tables Car & Rental Table for example :

Car Table
CarId ModelYear CarBrand Model Mileage ModelYear CarId
CA101 2008 Mahindra Scorpio 15 2008 CA101
CA102 2009 Suzuki 800 12 2009 CA102
CA103 2007 Hundai i20 5 2007 CA103
CA104 2007 Toyato Inova 3 2007 CA104
CA105 2009 BMW
5 2009 CA105
CA106 2010 Benz AZ12 10 2010 CA106


Rental Table
RentalId CustAccount CarId FromDate ToDate ToDate FromDate
RE101 1104 CA101 10/12/2010 10/29/2010 10/29/2010 10/12/2010
RE102 1102 CA102 11/17/2010 12/14/2010 12/14/2010 11/17/2010
RE103 1203 CA103 11/24/2010 12/15/2010 12/15/2010 11/24/2010
RE104 1301 CA104 12/10/2010 1/5/2011 1/5/2011 12/10/2010
RE105 1304 CA101 1/3/2011 1/18/2011 1/18/2011 1/3/2011
RE108 1303




RE107 1202




RE106 2024 CA103 1/10/2011 1/29/2011 1/29/2011 1/10/2011


Inner Join
Select records from main table that have matching record form join table.
Main table record and join table records are joined together and show as single record.
Code
static void JoinExamples(Args _args)
{
CarTable carTable;
RentalTable rentalTable;
;
while select carTable join rentalTable
order by carTable.CarId
where carTable.CarId == rentalTable.CarId
{
info(strfmt("Car id is %1 renatla id is %2",carTable.CarId, rentalTable.RentalId));
}
}

Output


Outer Join
Select all the records from main table and related records from join table
If there is no match, the field from join table is empty
Code
while select carTable outer join rentalTable
order by carTable.CarId
where carTable.CarId == rentalTable.CarId
Output
Exists Join
Selecting record from main table only if there is matching record in join table.
It shoul be return only main table record, not a related table record.
Code
while select carTable Exists join rentalTable
order by carTable.CarId
where carTable.CarId == rentalTable.CarId
Output
Not Exists Join
Selecting record from main table only if there is not matching record in join table.
It is directly irrelevant to the Exists join.
Output

Link Type: Delayed


A pause is inserted before linked child data sources are updated. This enables faster navigation in the parent data source because the records from child data sources are not updated immediately.

Form Output

Form Design in Data Source Level:



Link Type: Active
The child data source is updated immediately when a new record in the parent data source is selected. Continuous updates consume lots of resources.
Link Type: Passive


Linked child data sources are not updated automatically. Updates of the child data source must be programmed on the active method of the master data source.





Writing Data to Text File in AX 2009 & 2012

static void DataToTxt(Args _args)
{
     PurchTable   purchTable;
     BinData     binData;
     TextBuffer  textBuffer;
   
     ;

    textBuffer = new TextBuffer();
    textBuffer.setText('');

    while select purchTable
            where purchTable.PurchStatus == PurchStatus::Backorder
     {
        textBuffer.appendText(strfmt('%1\r',purchTable.PurchId));
        textBuffer.appendText(strfmt('%1\r',purchTable.PurchName));
        textBuffer.appendText(strfmt('%1\r\n',purchTable.PurchStatus));

     }
     textBuffer.getText();
     binData = new BinData();
     binData.setStrData(textBuffer.getText());
     binData.saveFile(@"C:\Users\ADeveloper1\Desktop\batch.txt");

}