Monday, October 17, 2016

My new AX7 blog

I create a new blog for AX7, you can find AX7 updates from my new blog, here is a link:
https://ax7lab.wordpress.com

Happy DAXing !!!!

Friday, June 3, 2016

How to change the value of a default dimension of a record in AX 2012

The following job will give you an example, of how to change the value of a dimension within the default dimensions of a record (the example-job changes the value of the dimension costcenterof a customer). In this way and manner individual dimension values can be removed also.

static void changeDimensionValue(Args _args)
{
    DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage;
    DimensionAttribute dimensionAttribute;
    CustTable custTable = CustTable::find("US-014");
    DimensionValue oldDimensionValue;
    DimensionValue newDimensionValue = "011";
    DimensionDefault newDimensionDefault;

    #define.dimensionName("CostCenter")

    DimensionValue getDimensonValue(DimensionDefault _dimensionDefault)
    {
        DefaultDimensionView defaultDimensionView;
        select firstonly DisplayValue
        from defaultDimensionView
        where defaultDimensionView.Name == #dimensionName
            && defaultDimensionView.DefaultDimension == _dimensionDefault;

        return defaultDimensionView.DisplayValue;
    }

    // Get current value
    oldDimensionValue = getDimensonValue(custTable.DefaultDimension);

    // Build DimensionAttributeValueSetStorage
    dimensionAttributeValueSetStorage = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);
 
    // Remove old dimension value
    dimensionAttribute = DimensionAttribute::findByName(#dimensionName);
    dimensionAttributeValueSetStorage.removeDimensionAttributeValue(
        DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, oldDimensionValue).RecId);
 
    // Set new dimension value
    if(newDimensionValue != "")
    {
        dimensionAttribute = DimensionAttribute::findByName(#dimensionName);
        dimensionAttributeValueSetStorage.addItem(
            DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, newDimensionValue));
    }
 
    newDimensionDefault = dimensionAttributeValueSetStorage.save();

    ttsbegin;
    custTable.selectForUpdate(true);
    custTable.DefaultDimension = newDimensionDefault;
    custTable.update();
    ttscommit;

}

Thursday, August 6, 2015

Dynamics AX excel data import

I found very nice precise blog about excel imports for customer, vendors, transactions, GL products etc:


Happy Daxing !!!


 

Saturday, May 30, 2015

DMF Error on import the data into staging table: Exception from HRESULT: 0xC0048021 at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelper.DMFEntity.ShowPreview(Boolean isComposite)

I have been trying to import data from an Excel file using Data Import Export Framework. The mapping and validation works but when I try to import the data into staging table – I get the below error:

Exception from HRESULT: 0xC0048021  at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelper.DMFEntity.ShowPreview(Boolean isComposite)  at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelperService.Service.ServiceHelper.ShowPreview(DMFEntity entity)

Error:
Exception from HRESULT: 0xC0048021
at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelper.DMFEntity.ShowPreview(Boolean isComposite)
at Microsoft.Dynamics.AX.Framework.Tools.DMF.SSISHelperService.Service.ServiceHelper.ShowPreview(DMFEntity entity)

Solution:

The problem is caused by the DMConfig XML file.
Go to the DMConfig.xml file in the “C:\Program Files\Microsoft Dynamics AX\60\DataImportExportFramework” folder and replace the PipelineComponentInfo_Multicast, PipelineComponentInfo_ExcelSource and   nodes by the following:

    {33D831DE-5DCF-48F0-B431-4D327B9E785D}
 
 
    {9F5C585F-2F02-4622-B273-F75D52419D4A}
 
 
    {90E2E609-1207-4CB0-A8CE-CC7B8CFE2510}
 

Happy Daxing !!!!


Thursday, March 19, 2015

CompanyInfo VatNum or any other field Unretrieved issue

Recently I came across one strange issue related to Service Order > Worker description report, I got exception every time when I run this report, after doing some investigation I found that the VatNum field is used in DP class but when i open CompanyInfo table from AOT, I got 'Unretrieved' values of this VatNum for all rows. VatNum basically a string field and it should be either BLANK or having some values. After trying so many trick from google (restart AOS, refresh cache) i still got the 'Unretrieved' issue. I than decided to set this field explicitly from backend DB, in Dynamics AX 2012 R2 databases, it appears that the CompanyInfo table (for example) exists in the AOT but not in the actual SQL database. The columns & data that are supposedly contained in CompanyInfo (according to the AOT) are actually found in the DirPartyTable. This is in contrast to AX 2012 databases. So after manually delete 'NULL' value from VATNum on DirPartyTable to BLANK i than able to run the report successfully. So TWO key point here are :
  • To overcome the 'Unretrieved' issue you can directly replace column value from NULL to BLANK.
  • You can find CompanyInfo table in AOT but not from SQL DB, use DirPartyTable instead to fix your desired 'Unretrieved' field issue.

Happy DAXing !!!!

Thursday, November 27, 2014

Copy Custom field from PO line to Invoice line

Sometime we have a scenario where we have to copy custom field value from PO to invoice, to do this you have create similar field in VendInvoiceInfoLine table and set/copy the value from PO line to invoice line on VendInvoiceInfoLine.defaultRaw() method or in class VendDocumentLineType_Invoice.

Happy DAXing !!!!