Get default financial dimension values through X++ code

This topic is not new and we have lots of blogs available on it. Yasir Co-blogger also explained this quite well in his blog. The purpose to share this again here that I have did some minor modifications in his job to get both attributes (Value and Name) for Default dimension. Complete code is here.

static void GetDefaultDimensionAttributeName(Args _args)
{
    DimensionAttributeValueSetStorage    dimStorage;
    HcmPositionDefaultDimension          HcmPositionDefaultDimension;
    DimensionAttribute  DimensionAttribute;
    Counter                                               i;
    DimensionAttribute          dimAttr;
    DimensionAttributeValue     dimAttrValue;
    Common                      common;
    DictTable                   dictTable;
    str                         Name;
    str                         value;

    // get the dimension value from position    
    HcmPositionDefaultDimension = HcmPositionDefaultDimension::findByPositionLegalEntity(HcmPosition::findByPosition("000001").RecId,CompanyInfo::find().RecId);

    // make the dimension storage object    
    dimStorage = DimensionAttributeValueSetStorage::find(HcmPositionDefaultDimension.DefaultDimension);

    for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        // get attribute select here.
        select firstonly dimAttrValue
        where dimAttrValue.RecId == dimStorage.getValueByIndex(i)
        join dimAttr
            where dimAttr.RecId == dimAttrValue.DimensionAttribute;

        if (dimAttr && dimAttrValue)
        {
            dictTable = new DictTable(dimAttr.BackingEntityType);
            common = dictTable.makeRecord();

            if (common.TableId)
            {
                select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
                name = common.(dimAttr.NameAttribute);
                value = common.(dimAttr.ValueAttribute);
            }
        }
        info(dimAttr.Name +"----" +value + "----"+name);
    }
}

output image
i9

we can check the other examples on same topic from Yasir’s Blog – Microsoft Dynamics AX

How to get meaningful AIF messages on Web service consumer?

Sometime on your consumer code you don’t know the cause of error and you have to dig into it by looking at exception form with in AX. Although there is a way to get all the meaningful messages at your consumer end also.

Obviously “Include exception in fault” checkbox needs to be enabled on your inbound port.

inbound
After that small piece of code (Catch) block will help you to get the meaningful messages.

catch (System.ServiceModel.FaultException<AxIntegrationServiceRefCust.AifFault> aiffaultException)
            {
                AxIntegrationServiceRefCust.InfologMessage[] list = aiffaultException.Detail.InfologMessageList;

                foreach(AxIntegrationServiceRefCust.InfologMessage message in list)
                {
                    Console.WriteLine(message.Message);
                }

                return 0;
            }

Error in “Go to origin” — Alert rules notifications

a1

Error is

The form cannot find the context of the alert from here. Try to access the \’Number: 201/2013/2194530, Visa\’ record in a different way.

To fix this error we need to modify the class EVENTCONTEXTDRILLDOWN

a2

Needs to add below code inside drilldown method, code should be similar to existing code of ledgerJournalTable.

a33

Then later you can add range to your main form to filter the specific record

a4

Useful SQL Query (Part 3) – Remove database log from SQL

There are certain needs when you want to remove the database logs. Below SQL query will help you in that.

USE [master]

GO
ALTER DATABASE [TestDb] SET RECOVERY SIMPLE WITH NO_WAIT

DBCC SHRINKFILE(TestDbLog, 1)

ALTER DATABASE [TestDb] SET RECOVERY FULL WITH NO_WAIT

GO

Follow

Get every new post delivered to your Inbox.

Join 328 other followers

%d bloggers like this: