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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

DimensionAttributeValueSetStorage.addItemValues error

(0) ShareShare
ReportReport
Posted on by 351

Hi all,

I have a parameter form lookup [Business unit, costCenter, project,,,,,,

 DimensionDefault DimensionVlaueName()
    {
        DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();
        DimensionDefault                    result;
        DimensionAttributeValueSet      dimAttrValueSet;
        DimensionAttributeValueSetItem  dimAttrValueSetItem;
        DimensionAttributeValue         dimAttrValue;
        Description255                  backingname, dimensionValueName;
        ;

        dimAttrValueSet = DimensionAttributeValueSet::find(ProjTable::find(this.ProjId).DefaultDimension);

        while select  DimensionAttributeValue from dimAttrValueSetItem
        where  dimAttrValueSetItem.DimensionAttributeValueSet   == dimAttrValueSet.RecId
        {
            backingname     = DimensionAttribute::find(DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue).DimensionAttribute).Name;
            dimAttrValue    = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);

            if(backingname == LIParameters::find().Branch) //description of the financial dimension
            {
                valueSetStorage.addItem(dimAttrValue);
            }
        }

        result = valueSetStorage.save();

        return result;
    }

As i mentioned above code mergedimension, its come as expected value but, getting error after update value.

Error : 

Function DimensionAttributeValueSetStorage.addItemValues has been incorrectly called.
How to resolve this error.
Thanks 
I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi waytod365,

    This error will be thrown when "DimensionAttrtibute" value RecId returning 0. So from your code dimAttrValue.DimensionAttribute is 0.

    Refer to the class DimensionAttributeValueSetStorage - additem() - Inside addItem() method they will be calling addItemValues - On the addItemValues method you can see if dimAttrValue.DimensionAttribute  is equal to 0 then the above error will be thrown.

    Thanks,

    Girish S.

  • waytod365 Profile Picture
    351 on at

    Thanks for your replay Girish S,

    As you mentioned addItem() how to overcome if not equal zero ? would be great if you could example.

    Thanks

  • GirishS Profile Picture
    27,827 Moderator on at

    Can you explain me the functionality you are doing?

    Thanks,

    Girish S.

  • waytod365 Profile Picture
    351 on at

    Thanks , I have a custom form and project id field has relation with a ProjTable.

    Parameter form : Lookup [BusinesUnit, CostCenter, Project, Worker, ItemGroup]

    Based on a parameter description(lookup)  i want to update my custom dimension.

    Etc : If i select parameter form costCenter then in my custom i select it project id : 00002.  (00002 against costCenter there in project table then update to costcenter in my custom dimension ). so that what to be done?

    Thanks

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    So the code should look something like below. Check if its work for your scenario.

    DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();
    DimensionDefault                    result;
    DimensionAttributeValueSet          dimAttrValueSet;
    DimensionAttributeValueSetItem      dimAttrValueSetItem;
    DimensionAttributeValue             dimAttrValue,dimAttrValue1;
    Description255                      backingname, dimensionValueName;
    DimensionAttribute                  attribute;
    
    dimAttrValueSet = DimensionAttributeValueSet::find(ProjTable::find(this.ProjId).DefaultDimension);
    //get the DimensionAttribute from the parameer form.
    select * from attribute
     where attribute.Name == paramterControl.value();
    while select  DimensionAttributeValue from dimAttrValueSetItem
        where  dimAttrValueSetItem.DimensionAttributeValueSet   == dimAttrValueSet.RecId
        {
            //backingname     = DimensionAttribute::find(DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue).DimensionAttribute).Name;
            //get the current dimension value.
            dimAttrValue    = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);
            //get the new dimension value based on the dimension attribute(Cost centre, Business unit etc).
            dimAttrValue1= DimensionAttributeValue::findByDimensionAttributeAndValue(attribute, dimAttrValue.DisplayValue,false,true));
            if(backingname == LIParameters::find().Branch) //description of the financial dimension
            {
                valueSetStorage.addItem(dimAttrValue1);
            }
        }
    
    result = valueSetStorage.save();
    
    return result;

    Thanks,

    Girish S.

  • waytod365 Profile Picture
    351 on at

    Thanks for your answer ,

    I tried above your code but, its getting error when i select project id and parameter form i set BusinessUnit.

    error :  

    Unable to return DimensionAttributeValue record for Dimension BusinessUnit with value 011 as no record exists in table OMOperatingUnit through view DimAttributeOMBusinessUnit.
  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at

    I think you need to check the requirement with functional. I will explain you the issue when you are updating "DimensionAttribute" name for the Project.

    Lets assume you have project "Project A" with dimension value like - Dimension attribute name  : "Business unit"  - Display value : "086".

    Now you have given "CostCenter" in parameter form - On the custom form you are giving "Project A".

    As per your code it will check in "DimensionAttriuteValue" table with DimensionAttribute as "CostCenter" and display value as "086". There wont be any such combination in DimensionAttributeValue table.

    Refer to the form for financial dimension setup - General Ledger >> Charts of accounts >> Dimension >> Financial dimension. On this form you will see all the Dimension attribute names with the display values. Select one dimension name and click on "Dimension value" from action pane - So only values available in the form will be used against the dimension name.

    Also the dimension values will be auto - populated in the above form from navigation path Organization administration >> Organizations >> Operation unit. Restriction will be you can create display value with value 086 only once. Already 086 value is assigned to "Business unit" .So you cannot create one more record with 086 and assign it to "CostCenter".

    I guess you need to check these requirement with functional and explain about the issue for updating dimension attribute name.

    Hope its clear.

    Thanks,

    Girish S.

  • waytod365 Profile Picture
    351 on at

    Thanks for your valuable suggestion girish,

    I understood, what is your point of view in it. ? an alternative way ?

    Thanks

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Okay then, My suggestion will be, In the parameter form add a field "Display value" below the Dimension attribute name.

    Lookup of the display value will show only values related to the Dimension attribute name. Suppose you have selected "Cost center" then Display value lookup will show only the values that belongs to "Cost center". This way you can restrict user to select only display values that are available in the "DimensionAttributeValue" table.

    Later based on the selection you can create new dimension value combination using "DimensionAttributeValueSetStorage" class  and update the values against the project id.

    Thanks,

    Girish S.

  • waytod365 Profile Picture
    351 on at

    Okay thanks, i can give it to display name against display value. then as you mentioned your code anything need to change if so, give me as well.

    Thanks 

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans