Posts

Showing posts from August, 2017

Canceling purchase order and sales order lines

Canceling purchase order lines        PurchLine purchLine;        ttsbegin;        while select forupdate purchLine where purchLine.PurchId == 'PO-XXXXXX'        {            if (purchLine)            {                purchLine.RemainInventPhysical  = 0;                purchLine.RemainPurchPhysical   = 0;                purchLine.update();                              InventMovement::bufferSetRemainQty(purchLine);             }         }         ttscommit; Canceling sales order lines        SalesLine salesLine;        tt...

Deleting purchase order orphan records in Ax 2009

Job to delete purchase order orphan records.     TimeInMS                                endTime;     TimeInMS                                startTime;     InventTransId                           inventTransId;     InventQtyMarked                         inventQtyMarked;     InventTransRefId                        inventTransRefId;     InventDim                               inventDimJoin;     InventDim                           ...

Unpick sales order through code in Ax 2009

Below job is to unpick sales order two lines and remove reservations.     InventTrans InventTrans;     TmpInventTransWMS   tmpinventTransWMS;     InventMovement  movement;     InventTransWMS_Pick inventTranspick;     InventTransId conInventTransId;     Qty     conVariantQty;     WMSOrderTrans wmsOrderTrans;     SEMKITSALESTRANS    SEMKITSALESTRANS;     //Remove any existing reservations     InventTrans            inventTransReserve    ;     InventMovement         inventMovement        ;     InventUpd_Reservation  inventUpd_Reservation ;     ;     while select SEMKITSALESTRANS         where SEMKITSALESTRANS.SalesId == 'SO-0014445'         && (SEMKITSALESTRANS.LineNum == 7...

Job to import data from excel in Ax 2009

Below job is to update a field value in inventtable from excel.     InventTable                     inventTable;     int                                     row = 1;     SysExcelApplication      sysExcelApplication_Import;     SysExcelWorkbooks       sysExcelWorkBooks_Import;     SysExcelWorkbook        sysExcelWorkBook_Import;     SysExcelWorkSheets      sysExcelWorkSheets_Import;     SysExcelWorkSheet       sysExcelWorkSheet_Import;     SysExcelStyles               sysExcelStyles_Import;     SysExcelStyle                sysExcelStyle_Import;     SysExcelFont         ...

Programmatically export and import product model details in Ax 2009

Job to export product model details to a given location.     FileName    filename = @"D:\ProductBuilder\";     PBAExport   sysDataExport;     PBATable    pbaTable;     ;     try     {         while select pbaTable         {             sysDataExport = PBAExport::newPBAExport();             sysDataExport.initPBAId(pbaTable);             sysDataExport.parmFilename(filename+pbaTable.PBAId);             sysDataExport.parmFiletype(FileType::Binary);             sysDataExport.run();         }         Info("Export completed successfully");     }     catch(Exception::Error)     {         error("You do not have acce...

Job to reset the price of return orders with price in Ax 2009

Job to reset the price of return orders with price in Ax 2009.     boolean                 updateprice = true;     SalesTable              salesHeader;     SalesLine               saleLine, saleLineUpdate;     DataArea                dataArea ;     TextIo                  file;     FileName                filename = @"c:\temp\RMAWithPriceList.txt";     FileIoPermission        permission;     #File     ;     try     {         // Create the permission class         permission = new FileIoPermission(filename, #io_write);         // Add a request for permis...

Job to delete un-posted journals in Ax 2009

Simple job to delete un-posted journals in Ax 2009     LedgerJournalTable  LedgerJournalTable;     LedgerJournalTrans  LedgerJournalTrans;     Container           journalList = [['DAT','JN-011111']];     str 10              company,journalnum;     int                 i;     ;     for(i=1; i <= conlen(journalList); i++)     {         [company, journalnum] = conpeek(journalList,i);         info(strfmt("%1 - Company: %2, JournalNum: %3", 1, company,journalnum));         changecompany(company)         {             LedgerJournalTrans = null;             LedgerJournalTable = null;             ttsbegin;   ...

Environment issues faced during an ASP dot net project web deploy

Image
Recently I got a chance to work on a ASP dot net project web deploy and come across below issues. After installing visual studio 2015 Update 3, I was getting below error while opening the solution. The imported project "C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exist on disk.   To fix the above error I had to install Visual Studio 2015 Tools (Preview 2):  https://go.microsoft.com/fwlink/?LinkId=827546 Then had Windows 7 know issue which was failing package restore. I could resolve the package restore by disabling virtual box adapter as explained in below two links. https://github.com/dotnet/cli/issues/2524 https://github.com/dotnet/cli/issues/1732 After that I was getting 200+ compilation issue as dot net framework 4.6.2 was not present in my system. Even after installing dot net framework...

Writing a unit test case for a simple class in Dynamics 365 for Finance and Operations

Image
This is to show how to write a unit test case in Dynamics 365 for Finance and Operations for a simple class. I have created a class to do simple arithmetic calculation called “ MyCalculator ” and created “ MyCalculatorUnitTest ” unit test class. In this test class shown three ways of adding the test methods. 1)        Adding  [ SysTestMethodAttribute ]   attribute   2)        Prefix the case with “test” in the method name 3)        Adding  [ SysTestMethod ,  SysTestGranularityAttribute ( SysTestGranularity ::Unit)] attribute . After creating test cases it can be viewed in Test Explorer (Test > Windows> Test Explorer) as shown below. Main Class: class   MyCalculator {      real     valueA,valueB;      public   void  setValueA( real  _a)     { ...