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
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.
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.
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'
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?
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");
}
}
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.
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
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156