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, ...
Suggested Answer

Update Financial Dimension value

(0) ShareShare
ReportReport
Posted on by 405

Hello,

I want to update Financial dimension value from 001 to blank (Null).

can we update using X++ code?  

I have the same question (0)
  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi Shubham,

    Instead of trying to code this, have you tried using the standard ledger allocation rule functionality to identify the 'empty' findim posting combinations and post them to the correct one?

    Best regards,

    Ludwig

  • shubhi gupta Profile Picture
    405 on at

    Hi Ludwing,

    i want to update BusinessUnit using code.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Shubham,

    On which form are you trying to change this dimension value?

  • shubhi gupta Profile Picture
    405 on at

    Hi Gunjan,

    i am writing below code but findByDimensionAttributeAndValue method giving error because we cant' pass blank value.

           inventJournalTrans.selectForUpdate(true);

           dimStorage        = DimensionAttributeValueSetStorage::find(inventJournalTrans.DefaultDimension);

           dimAttr           = DimensionAttribute::findByName(#DimensionName);

           dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr,'' , true, true);

           dimStorage.addItem(dimAttributeValue);

           defaultDimension    = dimStorage.save();        

           inventJournalTrans.DefaultDimension = defaultDimension;

           inventJournalTrans.Update();

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi Shubham,

    Are you sure that this is allowed in your country/region?

    If somebody would adjust posted transactions incl. findim values in my home country, there would be a lot of trouble with the auditors.

    I would recommend that you double check this with your finance team before applying your code adjustment.

    Best regards,

    Ludwig

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Shubham,

    Please try this code and check if it works for you.

    DefaultDimensionView defaultDimensionView;
           
    inventJournalTrans.selectForUpdate(true);
    
    dimStorage        = DimensionAttributeValueSetStorage::find(inventJournalTrans.DefaultDimension);
    dimAttr           = DimensionAttribute::findByName(#DimensionName);
    
    select firstonly DisplayValue
        from defaultDimensionView
        where defaultDimensionView.Name			        == dimAttr.Name
    		  && defaultDimensionView.DefaultDimension	== inventJournalTrans.DefaultDimension;    
    
    dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr,defaultDimensionView.DisplayValue , true, true);
    dimStorage.removeDimensionAttributeValue(dimAttributeValue.RecId);
    defaultDimension    = dimStorage.save();        
    inventJournalTrans.DefaultDimension = defaultDimension;
    
    inventJournalTrans.update();

  • shubhi gupta Profile Picture
    405 on at

    Hi Gunjan,

    i am getting same below error using you code also.

    Unable to return DimensionAttributeValue record for Dimension BusinessUnit with value <blank> as no record exists in table DimensionFinancialTag through view DimensionFinancialTag

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Shubham,

    Are you able to update the business unit value to "Blank" from the UI?

  • shubhi gupta Profile Picture
    405 on at

    Hi Gunjan,

    UI side i can update "Blank" value

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Shubham,

    I just tried the code on my Dev environment and it worked fine. Can you try to debug and check where the error is being thrown from?

    DefaultDimensionView                defaultDimensionView;
    DimensionAttributeValueSetStorage   dimStorage;
    DimensionAttribute                  dimAttr;
    DimensionAttributeValue             dimAttributeValue;
    InventJournalTrans                  invJourTrans = InventJournalTrans::findInventTransId("012691", true);
    DimensionDefault                    defaultDimension;
    
    ttsbegin;
    
    dimStorage        = DimensionAttributeValueSetStorage::find(invJourTrans.DefaultDimension);
    dimAttr           = DimensionAttribute::findByName("Department");
    
    select firstonly DisplayValue
        from defaultDimensionView
         where defaultDimensionView.Name			    == dimAttr.Name
            && defaultDimensionView.DefaultDimension	== invJourTrans.DefaultDimension;
    
    dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr,defaultDimensionView.DisplayValue , true, true);
    dimStorage.removeDimensionAttributeValue(dimAttributeValue.RecId);
    defaultDimension    = dimStorage.save();
    invJourTrans.DefaultDimension = defaultDimension;
    
    invJourTrans.update();
    
    ttscommit;

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 503 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans