Search This Blog

Monday, December 9, 2013

Caching inside AX

Hi Friends,

I found this useful article about "How Caching mechanism is been used inside the DAX..?"

Click here to read the content.

Happy Daxing..,
Sai
 

Tuesday, December 3, 2013

How to stop manual Refresh (F5) on Forms in AX...?

Hi Friends,

By doing a small code change in "SysSetupFormRun" class  we can stop the manual refresh(F5) on any form in AX.

We need to add some code in "task( )" method.

Ex :-

public int task(int _p1)
{
    #task
    FormDataSource formDataSource;
    int ret;
    if (_p1 == #taskFilter)
    {
        formDataSource = this.objectSet();
        if (formDataSource &&
            formDataSource.queryRun() &&
            formDataSource.queryRun().args() &&
            !formDataSource.queryRun().args().caller())
        {
            formDataSource.queryRun().args().caller(this);
        }
    }


   //Custom Code Start>>
  // Stopped manual Refresh on InventTable (Form)
    if ((_p1 == 2876) && // taskF5
        (this.name() == formStr(InventTable )))
    {
        return ret;
    }
   //Custom Code End <<

    ret = super(_p1);
    return ret;
}

Happy Daxing,
Sai.

Wednesday, November 20, 2013

How to add Filter functionality to Display method in dynamics AXAPTA

Hi Friends,


Normally filters will work only in table fields but we can't do filters to display method.

This below code will work for filters to display method also.

Step 1:
Go to the form design right click on particular control properties Auto Declaration No to Yes.



Step 2:
Override the context() method on the display method .

public void context()
{
    int             selectedMenu;
    formrun         fr;
    Args            ag;
    Name            strtext;
    querybuilddataSource qb1;
    queryrun    qr;
    query       q;
    PopupMenu menu = new PopupMenu(element.hWnd());
    int a = menu.insertItem('Filter By Field');
    int b = menu.insertItem('Filter By Selection');
    int c = menu.insertItem('Remove Filter');
    ;
q   = ItemControl_ds.query();
qb1 = q.dataSourceTable(tablenum(ItemControl));
qb1 = qb1.addDataSource(TableNum(SalesTable));
qb1.addLink(FieldNum(ItemControl,PO),FieldNum(SalesTable,PurchOrderFormNum));  

selectedMenu = menu.draw();
    switch (selectedMenu)
    {
    case -1: //Filter by field
            break;
    case a:
            ag = new args('SysformSearch');
            fr = new formrun(ag);
            fr.run();
            fr.wait();
//Reading User entered value for filter process
            strtext = fr.design().controlName('FindEdit').valueStr();
            if(strtext)
            {
//Creating a query for filter
                
                qb1.addRange(FieldNum(SalesTable,SearchName)).value(strtext);
                ItemControl_ds.query(Q);
                ItemControl_ds.executeQuery();
            }
            break;

    case b:                                      // Filter By Selection
           
            qb1.addRange(FieldNum(SalesTable,SearchName)).value(ProjName.valueStr());
            ItemControl_ds.query(Q);
            ItemControl_ds.executeQuery();
            break;

    case c :                                      // Remove Filter
            q   = new Query();
            qb1 = q.addDataSource(tablenum(ItemControl));
            qb1.clearLinks();
            qb1.clearRanges();
            ItemControl_ds.query(Q);
            ItemControl_ds.removeFilter();
            break;

    Default:
            break;
    }

}
After adding the above code we are getting menus like 


Happy Daxing..



Thursday, November 14, 2013

How to pass control value in form to class in AXAPTA

How to pass control value from from to class in AX2009

Step :1

Write the method in Form level like :

public str method1()

{

         return control.Text();

}
Step 2:

Write this code in class level where we need to use the value

 if(formHasMethod(args.caller(), identifierStr(MethodName)))
    {
       strcustname =  args.caller().MethodName();
   

   }


Happy Daxing...!

Tuesday, November 12, 2013

Avoid warning message for "Empty compound statement" in AXAPTA

How to  avoid warning message like "Empty compound statement" in AXAPTA

As:
Simply call the below method inside your while loop or catch block to avoid best practice error

Call exceptionTextFallThrough(); in the block. It does nothing, it's there just to say that you're intentionally not doing anything there (and to satisfy compiler).


Happy
Daxing.....

Wednesday, October 30, 2013

reRead( ) in AX 2009 - Best Advantage

Hi Friends,

I hope all of you may already know about this, but I am forced to post it here.

To avoid most of the UpdateConflicts / DeadLock errors while update a record in a table, just use the "reRead( )" method of the table before making any changes to the selected record of the table.

Ex :

;

ttsbegin;

select forUpdate tSalesLine where tSalesLine.SalesId = = 'SO-1234567';

tSalesLine.reRead( );

tSalesLine.Feild1 = XXXXX;
tSalesLine.Feild2 = XXXXX;

tSalesLine.update( );

ttscommit;

Happy Daxing..
AX Dude.

Tuesday, October 22, 2013

Setup & Config of AX 2012 R2 VM in VirtualBox

Hi Folks,

Here are the Links to Configure and instal Ax2012 VPC to Oracle Virtual BOX.

http://www.youtube.com/watch?v=klV6qh211EI

Thanks
Happy Daxing...!

Friday, October 18, 2013

Enterprise Portal With SharePoint 2013 Installation & Configuration For Microsoft Dynamics AX 2012 R2

Hi Friends

I found a very good post to install and configure Enterprise Portal With SharePoint 2013 Installation & Configuration For Microsoft Dynamics AX 2012 R2.



Thanks
Happy Daxing..!

Tuesday, October 15, 2013

How to Cancel a Sales Order in AX using X++

Hi All,

To cancel a sales order using X++ I tried the below code, I hope it will be helpful for you.

ttsBegin;
    while select forupdate salesLine
        where salesLine.SalesId == salesTable.SalesId
    {
        salesLine.RemainInventPhysical = 0;
        salesLine.RemainSalesPhysical  = 0;
        salesLine.update();
    }
ttscommit;

Happy Daxing,
AX Dude

Finding out which tables were updated by an operation in AX

Hi All,

At times when troubleshooting Microsoft Dynamics AX you need to know which tables were updated by a particular operation, for example after performing a posting. This could be if you want to be sure that all the right tables are updated correctly after an upgrade, if you have unexpected results on one customer/vendor etc or if you have made an update the system and you want to be sure that everything is ok.

Click Here to continue to the post.

Happy Daxing,
AX Dude

Friday, October 4, 2013

How to find USR Layer objects in entire AOT

Hi Guys,

I found some instersting content about how we can find the USR layer code in entire AOT.

Click Here

Happy Daxing,
AX Dude

Monday, September 30, 2013

RPC errors when calling WinAPI method from a batch job.

Hi Guys,

I found a very good article about the errors and issues when we are calling WinAPI class from a Batch job.

Click here to read the content.

Happy Daxing,
AX Dude.

Thursday, September 26, 2013

Troubleshooting BizTalk Web Services - AX 2009

Hi Guys,

how to identify and resolve common Web service issues.

Click here to see the content.

Happy Daxing,
AX Dude.

How to: Trace a Call to an AIF Web Service

Hi Guys,


How to trace a call from an external client to an X++ service exposed as a Web service in Microsoft Dynamics AX. When you call the Web service, the call goes to the Web service and is then passed to the AOS. You can use tracing to capture the parameters the client sends to the Web services as well as the parameters that are sent from the Web service to the AOS.

Click here to see the content.

Happy Daxing,
AX Dude.

Wednesday, September 25, 2013

How to delete the file from particular location in Axapta


 WinApi::deleteFile(filepath);


Happy Daxing...

strLfix & strRfix Function - Append zeros to the String - AX 2009

Hi Folks,

The following code used to append zeros to the string either left /Right.

static void Append(Args _args)
{
    int i = 1;
    str Append;
    str finalResult;
    ;

   Append= strlFix(int2str(i), 5, "0"); // Create a string, with a length of 5, ending with the value of ''i'' and padded with zeros
finalResult = strFmt("%1", Append);
info(finalResult);

}

o/p:10000


Happy Daxing.....

Remove the characters from string and convert to date to str in Axapta

Hi Folks,

strRem and date2str
Below job are to explain about how remove the characters from date and time in axapta

static void Job131(Args _args)
{
    str st;
    ;
    st = strRem(date2str(today(),213,2,0,2,0,4)+time2str(timenow(),                       TimeSeparator::Space,TimeFormat::Auto)," ");
    info(st);
}

Normally date and time will display like 09/25/2013 07:14:30 Am
By using date2str it will convert the date to str and again remove the character also .

O/P:09252013071430am

Thanks
Happy Daxing...

Using File path on a form getting Error in Axapta

Hi Folks,

After a long time am coming  back to posting few new things here for AX Developer...

When we want to select the file path in form level. Normally what we will do create one EDT and extends with filepath (EDT), but that time when you are trying to select the path we will get error like stack-trace/Error message .Don’t worry there is no problem with your ax application. Simple we need to provide the method to the form like filepathLookUpTitle ().
Below method we need to add it into form level methods, i.e.

str filePathLookupTitle()
{
    return "Select document folder";
}

Thanks
Happy Daxing....

Friday, September 20, 2013

What are the diffrences between "index" & "index hint" in X++

Hi Guys,

I found a useful link which explaines about "index" and "index hint".

Click here

Happy Daxing,
AX Dude.

Thursday, September 19, 2013

Create/Delete Customer using AIF Service Class in Dynamics AX without AIF Setup

Hi Guys,

The Application Integration Framework allows us to create/update/delete or read data. Now in AX2009 we have a facility of creating/deleting records using AIF Service classes. There is "NO ADDITIONAL AIF SETUP"(Like Enabling Endpoints etc.) required to execute the code via service class. The services can be used to read/write data in AX.
Click here to see the cource page.

Thanks,
AX Dude.

Friday, September 13, 2013

Dynamics AX Performance Optimization Guide

Hi Guys,

Yesterday I was in browsing to find some DAX performance oprimization tips as I am working on performance issues in AIF,AOS, SQL Traces and Batch Job optimizations. I found an interesting book.

Click here to read a brief review about that book.

Happy Daxing...!
AX Dude

Thursday, September 12, 2013

Performance Analyzer for Microsoft Dynamics

Hi All,

                    Performance Analyzer for Microsoft Dynamics (Performance Analyzer) is the tool used by Microsoft Dynamics support, Premier Field Engineers, and product team members to diagnose performance issues with Dynamics products.

Click here to download

Happy Daxing....!
AX Dude.

Monday, August 26, 2013

Document Handling in AX 2009

Hi Guys,

Document Handling is very useful to attach files related to AX data to forms. It’s possible to add data at any form. I found a useful source for "How to setup Document Handling in AX 2009"

Click here to view the content.

Happy Daxing....!



Thursday, August 22, 2013

Emailing Customer Invoices from a batch

Hi Guys,

The batch process to emailing the invoices to the Customers.

Click here

Happy Daxing...!

Wednesday, August 21, 2013

Inside Dynamics AX 4.0, AX 2009 Transaction Semantics

Hi Guys,

I found some transacation semantics, which are good to know to fix frequesnt error message

"Stack trace: Call to TTSCOMMIT without first calling TTSBEGIN."

Click here

Happy Daxing....!
AX Dude.

Tuesday, August 6, 2013

Friday, July 26, 2013

How to uninstall SP1 from windows server 2008 r2 (KB: 976932)

Step 1

Login into windows server r2 , there go to command prompt with administrator rights (Run as administrator)

Step 2

Type the cmd
Wusa /uninstall /kb: 976932 and press enter uninstall bar will come it will take 10 to 15min to uninstall the server pack1 from server.

Step 3

Using this commands we have to remove sp1 setup backup files from windows server OS 2008 r2
Dism.exe /online / Cleanup-Image /spsuperseded



Happy Daxing..

Tuesday, July 16, 2013

Test Data Transfer Tool for Microsoft Dynamics AX 2012 – Part 1

Test Data Transfer Tool for Microsoft Dynamics AX 2012-Part 2

How to avoid displaying negative values in the report in Axapta 2009 Using X++

Hi Friends,

change negative sign to positive   in Axapta 2009

As: it’s very easy task, normally we will do it like go to property’s simply we will change the signdisplay = none
Ex: Qty is -10
I want to display qty: 10
But here my requirement is wants to change the sign based on one condition in my Report.
If that field is in display method I will write the condition and I will do it, it’s not a display method.
This case we need to write the X++ code before sending data to body we need to write the
Below single line of code: i.e.

If (Table.SalesType == salestype::ReturnItem)
 {

        (
Control Name)Table_Qty. SignDisplay (signDisplay::None);
  }                 

Folks share your ideas,This my idea..

Happy 
Daxing...                

                            

Monday, July 15, 2013

OpenPrinter_1: rc:0 lastError:1801(0x709) The printer name is invalid In Axapta 2009

When I open  the report getting the below in Dynamics AX 2009
Error message as below:
"OpenPrinter_1: rc:0 lastError:1801(0x709) The printer name is invalid."

Actually 2 places we need to Change


First Place:

      Classes->RunBaseReportDialog->main() 

static void main(Args args)
{
    RunBaseReportDialog     reportDialog    = new RunBaseReportDialog(args.caller());
    RunBaseReport           runBaseReport   = args.caller().runbase();
    ReportRun               reportRun       = runBaseReport.reportRun();
    Report                  report          = reportRun.report();
    boolean                 oldInteractive;
    boolean                 res;
    Dialog                  dialog;
;

    oldInteractive = report.interactive();
    report.interactive(true);

    //res = reportRun.prompt();  
 //removed
    res = reportDialog.prompt();  //Added 

    report.interactive(oldInteractive);
    if (!res)
        return;

    dialog = Dialog::getDialogFromCaller(args.caller());
    if (dialog)
    {
        dialog.updateServer();
    }
    runBaseReport.dialogUpdatePrinterSettings(dialog);
    reportDialog.run();
}
Second One:

Change the report design Property  orientation:Auto


Happy Daxing....:)


Display Method How Goto MainTable Functionality Works In Axapta 2009

Hi Friends,

Recently i got requirement from my customer,that is very simple you know what is that,Customers is asking GotoMainTable Functionality for one field ,i.e display method: Just Simple

Override JumpRef() under design ->Control ->

public void jumpRef()
{
    Args args;
    MenuFunction menuFunction;
    SalesTable salesTableLocal;
    str val2;
    ;
    super();
    while select salesTableLocal where salesTableLocal.SalesId == SO.valueStr()
    {
               val2 = salesTableLocal.SalesId;
                args = new Args();
                //  args.caller(this);
                args.parm(val2);
                args.record(salesTableLocal);
                args.parmEnum(AllChosen::Chosen);
                menuFunction = new MenuFunction(menuitemdisplaystr(SalesTable),                     MenuItemType::Display);
                menuFunction.run(args);
    }
}
 Feel free to contact me have any doubt...

Happy
Daxing...!


Monday, July 8, 2013

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..