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 
  • GirishS Profile Picture
    27,825 Moderator on at
    RE: DimensionAttributeValueSetStorage.addItemValues error

    You said it's not going into while select statement. Thats why I asked you to check whether values are present in the "DimensionAttributeValueSetItem" table. You can open the table browser in the url and check whether values are there in "DimensionAttributeValueSetItem" against "DimensionAttributeValueSet". table.

    Debug the code and find out the RecId values for "DimensionAttributeValueSet" buffer(dimAttrValueSet) on line number 37.

    Now you can find the values in the "DimensionAttributeValueSetItem"(open the table in browser) against the DimAttributeValueSet(dimAttrValueSet.RecId) buffer.

    Thanks,

    Girish S.

  • waytod365 Profile Picture
    351 on at
    RE: DimensionAttributeValueSetStorage.addItemValues error

    case fieldNum(LRTripRequest, ProjId):  //modifiedField method
    {
        if(parameter.UpdateDimension == UpdateDimension::ProjectWorker)
        {
            this.mergeProjectDimensionDefault();
          
        }
    }
    
    case fieldNum(LRTripRequest,Worker):  //modifiedField method
    {
        if(parameter.UpdateDimension == UpdateDimension::ProjectWorker)
        {
            this.mergeProjectDimensionDefault();
          
        }
    }
    
    /// merge dimesion 
     protected void mergeWorkerCustomDimensionDefault()
        {
            
            this.DimensionDefault = this.mergeDimension(HcmEmployment::findByWorkerLegalEntity(this.Worker,CompanyInfo::find().RecId).DefaultDimension,  this.DimensionVlaueName2());
        }
        
    //    Method
     DimensionDefault DimensionVlaueName2()
        {
            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);
            
            select firstonly attribute
                where attribute.Name == LTParameters::find().ProjectName;
    
            while select  DimensionAttributeValue from dimAttrValueSetItem
                where  dimAttrValueSetItem.DimensionAttributeValueSet   == dimAttrValueSet.RecId
            {
                dimAttrValue    = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);
                dimAttrValue1  = DimensionAttributeValue::findByDimensionAttributeAndValue(attribute, LTParameters::find().ProjectValue,false,true);
                
                if(attribute.Name == LTParameters::find().ProjectName)
                {
                    valueSetStorage.addItem(dimAttrValue1);
                }
                
                
            }
    
            result = valueSetStorage.save();
    
            return result;
            
           
        }

    As i mentioned above code i already used merge dimension. and already there project id against value.

    I.e : You mean project id against costCenter and parameter costCenter value both are same correct me if I'm wrong.

    Thanks  

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: DimensionAttributeValueSetStorage.addItemValues error

    Does the selected project has dimension specified?

    Open the table browser of ProjTable - Get the value for "DefaultDimension" against the selected project - Open DimensionAttributeValueSetItem - Filter "DimensionAttributeValueSet field value with value taken from ProjTable "DefaultDimension" value. If there is no record means you done thave default dimension specified for project.

    Also please share your code here.

    Thanks,

    Girish S.

  • waytod365 Profile Picture
    351 on at
    RE: DimensionAttributeValueSetStorage.addItemValues error

    Yes! i debugged and its getting value as null in the "dimAttrValue1" buffer.

    Also its not go inside while loop. what could be the cases and resolutions?

    Thanks 

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: DimensionAttributeValueSetStorage.addItemValues error

    Have you debugged the code?

    Try to debug the code and check whether buffer "dimAttrValue1" has values.

    Thanks,

    Girish S.

  • waytod365 Profile Picture
    351 on at
    RE: DimensionAttributeValueSetStorage.addItemValues error

    Hi Girish S, 

    Actually i did what you said and i add it in the parameter form display value based on a display name.

    When I select project id which i mentioned first error come again. What could be the reason?

    Error:

    Function DimensionAttributeValueSetStorage.addItemValues has been incorrectly called.

    Once you free let me know.

    Thanks

  • waytod365 Profile Picture
    351 on at
    RE: DimensionAttributeValueSetStorage.addItemValues error

    Thanks for your time. :)

  • Verified answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: DimensionAttributeValueSetStorage.addItemValues error

    Code should look something like below.

    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);
            dimAttrValue1 = DimensionAttributeValue::findByDimensionAttributeAndValue(attribute, parameterControlDisplayValue,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
    RE: DimensionAttributeValueSetStorage.addItemValues error

    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 

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: DimensionAttributeValueSetStorage.addItemValues error

    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.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,336 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,025 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans