Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Issue with DimensionAttributeValueContract

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

  • ErikKornerup Profile Picture
    ErikKornerup 200 on at
    RE: Issue with DimensionAttributeValueContract

    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.

  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: Issue with DimensionAttributeValueContract

    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
    ErikKornerup 200 on at
    RE: Issue with DimensionAttributeValueContract

    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
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: Issue with DimensionAttributeValueContract

    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
    ErikKornerup 200 on at
    RE: Issue with DimensionAttributeValueContract

    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
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: Issue with DimensionAttributeValueContract

    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
    ErikKornerup 200 on at
    RE: Issue with DimensionAttributeValueContract

    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
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: Issue with DimensionAttributeValueContract

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans