Job to Import Vendor/Customer Postal Address in Dynamics Ax2012

The job is for importing vendor postal address, with minor modifications it can be used for Customer also. The is also for my business scenario, so might be require some minnor modification for any other business scenario.

 static void PostalAddressCreate(Args _args)
  
   {
  
     VendTable vendTable;
  
     DirParty dirParty;
  
     DirPartyPostalAddressView PostalAddress;
  
     CommaTextIo file;
  
     container record;
  
     str countyId, zipcode;
  
     ;
  
     file = new CommaTextIo("C:\\VendorPostalAddress.csv",'r');
  
     file.inFieldDelimiter(',');
  
     while (file.status() == IO_Status::Ok)
  
     {
  
       record = file.read();
  
       vendTable = VendTable::find(conPeek(record,1));
  
       if (vendTable.RecId)
  
       {
  
         try{
  
         dirParty = DirParty::constructFromCommon(vendTable);
  
         PostalAddress.Street = conPeek(record,2);
  
         PostalAddress.BuildingCompliment = conPeek(record,3);
  
         PostalAddress.City = conPeek(record,4);
  
         PostalAddress.CountryCurrencyCode = conPeek(record,5);
  
         PostalAddress.CountryRegionId = conPeek(record,6);
  
         countyId = conPeek(record,7);
  
         if (Global::strStartsWith(countyId,'~'))
  
         {
  
           countyId = strDel(countyId,1,1);
  
         }
  
         PostalAddress.County = countyId;
  
         //PostalAddress.District = conPeek(record,8);
  
         //PostalAddress.DistrictName = conPeek(record,9);
  
         //PostalAddress.IsLocationOwner = conPeek(record,10);
  
         //PostalAddress.isocode = conPeek(record,11);
  
         PostalAddress.IsPrimary = conPeek(record,12);
  
         PostalAddress.LocationName = conPeek(record,16);
  
         PostalAddress.State = conPeek(record,24);
  
         zipcode = conPeek(record,30);
  
         if (Global::strStartsWith(zipcode,'~'))
  
         {
  
           zipcode = strDel(zipcode,1,1);
  
         }
  
         PostalAddress.ZipCode = zipcode;
  
         PostalAddress.ValidFrom = datetobeginUtcDateTime(1\1\2012, DateTimeUtil::getUserPreferredTimeZone()) ;
  
         PostalAddress.ValidTo = datetobeginUtcDateTime(1\1\2154, DateTimeUtil::getUserPreferredTimeZone()) ;
  
         PostalAddress.Party = vendTable.Party;
  
         if (!dirParty.createOrUpdatePostalAddress(PostalAddress).RecId)
  
           {
  
             info(VendTable.AccountNum);
  
           }
  
         }
  
         catch(Exception::Error)
  
         {
  
           info(VendTable.AccountNum);
  
         }
  
       }
  
     }
  
   }  

Weighbridge device integration with Dynamics AX

Recently I got chance to work on Integration project where I need to integrate the Weighbridge device with dynamics ax. This was the hardware interfacing project, where I have used the API to read the serial port. The serial port was connected with the Weighbridge device and sending the weight information to that port.

Business needs

I have developed this software for a steel company where they have trucks coming with the weight. Weighbridge software captures the weight of the truck and stores in weighbridge software that we have developed in Dynamics AX 2009. Later we again capture the weight as the trucks goes out after unloading the material. So by netting out the two weights we would be able to get the material weight that is coming.

What is Weighbridge device and for what use it is?

If anyone would like to know what is that device and what is the use of that device. “A weighbridge is a really useful tool for measuring the maximum load which can be carried by a vehicle or other device”

Solution:

We have developed the weighbridge software in AX, (see picture below) that capture and records the weight of material coming in. The capture buttons are used to capture the weight from Serial Port, the interfacing logic is written in that. 

The weighbridge software is normal AX software the important thing is the Serial Port interfacing logic, which I have shown below. I have to use the .Net SerialPort classes in AX to develop the interfacing logic.

Happy Daxing, let me know if you have anything to ask in here.

SysComputedColumn implementation to add Computed Column in Dynamics Ax 2012 View

The purpose of this blog is to explore the new feature in dynamics ax 2012 through which you can use the computed columns in Dynamics ax View, complete class SysComputedColumns is available in AOT with lots of method in it. You can add any more based on your requirement and use them in your View as i have explained below through example.

1)     Create a method on SysComputedColumn class similar to:

publicstatic clientserver str len(str _expression)
{
return ‘LEN(‘ + _expression +’)’;
}

2)     Create a new view or select any existing and select the normal fields you want to the view from its datasource.

3)     Create a method on the view similar to:

publicserver staticstr mainAccountLength()
{
tableName viewName =tablestr(AbcTest);       // name of your view
str mainAccountLength;

mainAccountLength = SysComputedColumn::len(
SysComputedColumn::returnField(viewName,identifierStr
(MainAccount_1), fieldstr(MainAccount, name)));

//identifierStr(MainAccount_1) = name of the datasource in the view.

return mainAccountLength;
}
(I used \Data Dictionary\Views\ProjTransBudgetCube\Methods\projBudgetPayrollAllocation as a baseline)
The purpose here in this example is to use the computed column in Dynamics ax 2012 View.

4)     Rightclick on the view fields node and select new INT computed column

5)     Set the viewmethod = mainAccountLength (the method created above)

Another blog that also gives you an example about adding a computed columns in View