Thursday, December 31, 2020

Get financial dimension display value using x++

 Code to get dimension display value in ax 2012/D365 FO using x++ 


public str getDimensionDisplayValue(RecId _defaultDimension, Name dimName)
{
  DimensionAttributeValueSetStorage dimStorage;

  dimStorage = DimensionAttributeValueSetStorage::find(_defaultDimension);
  return dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName(dimName).RecId);
}
str dimensionValue;
dimensionValue = this.getDimensionDisplayValue(DefaultDimensionRecId, 'Project');

//Where
//defaultDimensionRecId can be PurchTable.Defaultdimension, InventTable.DefaultDimension etc
//'Project' is the name of the financial dimension. It can be 'BusinessUnit' 'CostCenter' etc.


Note: Please refer to the tables below to get display value name.
1. DimensionfinancialTagCtegory
2. OmoperatingUnit (OMOperatingUnitNumber, OMOperatingUnitType)


Tuesday, December 15, 2020

Get active financial dimensions in ax 2012 or D365 using x++

Below is the code to get active financial dimension in ax 2012 or D365 using x++


          DimensionAttributeSetItem  dimAttrSetItem;
          DimensionAttribute  dimAttr;
          DimensionEnumeration dimensionSetId;

          int dimAttrCount;

          dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger();

//Code to get count of active dimensions 

           select count(RecId) from dimAttr
                       where dimAttr.Type != DimensionAttributeType::MainAccount
                 join RecId from dimAttrSetItem
                        where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
                                   dimAttrSetItem.DimensionAttributeSet == dimensionSetId;

               info(strFmt("Total active financial dimensions for current legal entity: %1", dimAttr.RecId));

//Code to get active dimensions name

            while select * from dimAttr
                           order by Name
                           where dimAttr.Type != DimensionAttributeType::MainAccount
                     join RecId from dimAttrSetItem
                           where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&
                                      dimAttrSetItem.DimensionAttributeSet == dimensionSetId        
            {

                    info(dimAttr.Name);

             }


Enjoy :) 

Monday, December 14, 2020

Sync single table in ax 2012 or D365 FO using X++

 Sync a table in ax 2012 or  D365FO using x++.

Create a job in ax 2012 or runnable class in D365FO. Write the following piece of code in it and run the job.


appl.dbSynchronize(tableNum(TableName));


Friday, December 4, 2020

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:queryBuilderArgs.

 Getting following error while running report in ax 2012.


The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:queryBuilderArgs. The InnerException message was 'Element 'http://tempuri.org/:queryBuilderArgs' contains data from a type that maps to the name 'http://schemas.datacontract.org/2004/07/XppClasses:SRSQueryBuilderArgs'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver if you are using DataContractSerializer or add the type corresponding to 'SRSQueryBuilderArgs' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to the serializer.'.  Please see InnerException for more details.


Solution:

1. Stop AOS Service

2. Restart SQl Server Reporting Services

3. Start AOS service

4. Deploy BIServices from Service group in AOT.

5. Refresh report server from caches and reset Date usage (Optional)

Enjoy :)