web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Issue with DimensionAttributeValueContract

(0) ShareShare
ReportReport
Posted on by 200

When I address the class DimensionAttributeValueContract I transfer a value and a name.

This Name is a fixed value ('Business Unit', 'Department','Service Center') which reflects the different dimensionattribute names which you want to use in the class.

My problem is that in my developer box (based on Contoso) dimension[1] is named 'Business Unit' while the same dimension in the test environment is named 'Department'.

This means that when I test my code in Dev box I must use DimensionAttributeValueContract.ParmName('Business Unit'); and in test DimensionAttributeValueContract.ParmName('Department');

Is there a method that I can use to find the DimensionAttribute record from the dimension element, so I can use the call as DimensionAttributeValueContract.ParmName(method(Dimension[1].Name) and so forth for the rest of the dimensions?

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    239,364 Most Valuable Professional on at

    Where do you have something like Dimension[1]? It's exactly what has been replaced with the new dimension framework (named attributes) already in AX 2012.

  • ErikKornerup Profile Picture
    200 on at

    it was also ment to clarify.

    I have a list of dimensions which is shown in the same order. I want to get the name for the dimension that is shown first

  • Martin Dráb Profile Picture
    239,364 Most Valuable Professional on at

    What kind of list shown where?

    Please realize that we depend on what you tell us about your system and your problem and we can't help you don't tell us enough.

  • ErikKornerup Profile Picture
    200 on at

    I am using a method like this:

    My problem is that in my DEV box the business Unit (the first dimension shown in the D365 forms) is named 'Business Unit' and in my test environment it is named 'Department'.

    I am looking for a method to find out what the DimensionAttribute name for dimension that is shown first is.

    static void ValidateLedgerDimension(Args _args)

    {

      str mainAcctNum = "110130";

      LedgerAccountValidationContract validationContract;

      LedgerAccountContract           accountContract;

      DimensionAttributeValueContract valueContract;

      FinancialDimensionValidationService service;

      List listValueContract = new List(Types::Class);

      // Business Unit

      valueContract = new DimensionAttributeValueContract();

      valueContract.parmName("BusinessUnit");

      valueContract.parmValue("002");

      listValueContract.addEnd(valueContract);

      accountContract = new LedgerAccountContract();

      accountContract.parmMainAccount(mainAcctNum);

      accountContract.parmValues(listValueContract);

      validationContract = new LedgerAccountValidationContract();

      validationContract.parmLedgerAccount(accountContract);

      validationContract.parmValidDate(systemDateGet());

      service = new FinancialDimensionValidationService();

      if (service.validateLedgerAccount(validationContract))

      {

          info("Valid");

      }

      else

      {

          info("Invalid");

      }

    }

  • Martin Dráb Profile Picture
    239,364 Most Valuable Professional on at

    First of all, let me format your code to make it easier to read:

    // Business Unit
    DimensionAttributeValueContract valueContract = new DimensionAttributeValueContract();
    valueContract.parmName("BusinessUnit");
    valueContract.parmValue("002");
    
    List listValueContract = new List(Types::Class);
    listValueContract.addEnd(valueContract);
    
    LedgerAccountContract accountContract = new LedgerAccountContract();
    accountContract.parmMainAccount("110130");
    accountContract.parmValues(listValueContract);
    
    LedgerAccountValidationContract validationContract = new LedgerAccountValidationContract();
    validationContract.parmLedgerAccount(accountContract);
    validationContract.parmValidDate(systemDateGet());
    
    FinancialDimensionValidationService service = new FinancialDimensionValidationService();
    if (service.validateLedgerAccount(validationContract))
    {
        info("Valid");
    }
    else
    {
        info("Invalid");
    }
    

    Now we can finally see a bit about what you're doing - you're using FinancialDimensionValidationService.validateLedgerAccount() for some reason.

    Now let's talk about your problem. You said that you have different dimensions configured in your two environments, so it's it actually correct that you get different results?

  • ErikKornerup Profile Picture
    200 on at

    Thank you for the work :-)

    It is the same dimension - the first that is shown.

    I would therefore rather have a way to decide that in one environment it is named BusinessUnit and in the other it is named 'Department' in stead of hard coding 'BusinessUnit' and 'Department'

  • Martin Dráb Profile Picture
    239,364 Most Valuable Professional on at

    If I understand it correctly, you have two dimension attributes, "BusinessUnit" and "Department", which contain the same data.

    You indeed shouldn't hard-code business data inside code, therefore you should think about business meaning and implement this meaning, regardless of how users configure their data (such as how they call dimension attributes). For example, you may have a parameter where users identify which dimension attribute should be used for this purpose (whatever the purpose is).

    Hardcoding the order would be bad too, because it also depends on configuration.

  • ErikKornerup Profile Picture
    200 on at

    You are correct. I was hoping that there was a method to do that, but if not I will have to implement a parameter setting.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans