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

Offset Ledger Dimension Issue

(1) ShareShare
ReportReport
Posted on by 269
In response to a button click event, I am attempting to populate the LedgerJournalTrans table after performing certain calculations. However, I am encountering issues with the OffsetLedgerDimension field. Despite successfully retrieving values for all related variables, the OffsetLedgerDimension field still resolves to zero, and I am unable to determine the cause of this issue.
RecId offsetLedgerDimension = this.getLedgerDimension('56404001', businessUnit, itemId, vendorAccountNum);
       ledgerJournalTransVendInvoice.OffsetLedgerDimension = offsetLedgerDimension;

        ledgerJournalTransVendInvoice.insert();

in the above piece of code i am inserting the value i m getting after executing the getLedgerDimension .
public RecId getLedgerDimension(MainAccountNum mainAccount, str businessUnit, ItemId itemId, str vendorAccountNum)
    {
      DimensionAttributeValueContract dimensionAttributeValueContract;
      LedgerAccountContract ledgerAccountContract = new LedgerAccountContract();
      ledgerAccountContract.parmValues(new List(Types::Class));

      ledgerAccountContract.parmMainAccount(mainAccount);

      dimensionAttributeValueContract = DimensionAttributeValueContract::construct('BusinessUnit', businessUnit);
      ledgerAccountContract.parmValues().addEnd(dimensionAttributeValueContract);

      dimensionAttributeValueContract = DimensionAttributeValueContract::construct('Item', itemId);
      ledgerAccountContract.parmValues().addEnd(dimensionAttributeValueContract);


      dimensionAttributeValueContract = DimensionAttributeValueContract::construct('Vendor', vendorAccountNum);
      ledgerAccountContract.parmValues().addEnd(dimensionAttributeValueContract);


      LedgerDimensionCombinationServiceProvider dimensionServiceProvider = LedgerDimensionCombinationServiceProvider::newForLedgerAccountContract(ledgerAccountContract);
      DimensionStorageResult dimensionStorageResult = dimensionServiceProvider.resolve();

     

      return dimensionStorageResult.parmSavedRecId();
    }
in the above piece of code i am calculating the offsetledgerdimension but it return zero.
Environment : D365 F&O 
Only standard mehtods are available in my enviroment
I have the same question (0)
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi,
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Ayushaman Profile Picture
    269 on at
    Hi Waed Ayyad
     
    Thanks for the response .I took reference from this earlier and treid to implemented the same on my code as well but the offsetledgerdimension is zero. If you view the code snippet i am not able to find out why my ledgerdimension gets zero .

    Thanks ,
    Ayushaman
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi,
     
    Are you sure about the values? Did you try to check already exists record in LedgerJournalTrans, and try your code in Runnable class?
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
  • Ayushaman Profile Picture
    269 on at
    Waed ,
     
    Yes i m getting values for reference lets suppose 
    mainaccount : 56404001
    buisnessunit  : XYZ
    Itemid :1122K
    Vendor : VEND0003911
    I am sure about this because this gets filled when i click a button on my form and that way i debugged it. and these details are filled with different tables via select query. i am not passing rec id  i am directly passing value in parameter. i want to create a offsetledgerdimension with these. 
  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi,
     
    Sorry, but I don't understand " when I click a button on my form", which form do you mean?
     
     
    Thanks,
    Waed Ayyad
     
     
     
  • Ayushaman Profile Picture
    269 on at
    Waed,
     
    i have custom form in which i m doing  customisation and all in that i have a requirement of creating a new offsetledgerdimension based on mainaccount ,buisnessunit,itemid,vendoraccount. and insert it in ledgerjournaltrans table. i written the above code but its not working . the insertion process triggers when a custom button is clicked.this might have clarified you the requirement.Thanks for assisting me  in this issue .I appreciate it
     
    Thanks,
    Ayushaman
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi,
     
    Do you have already existed data In the LedgerJournalTrans before the new customization, If yes, just I want you to try to call your new method on the already exists record's data (main Account, business Unit, etc.) and see if the ledgerDimension field that saved on that record is matching the result of your method. I want to make sure if the issue on the method or the data.
     
    Thanks,
    Waed Ayyad
     
     
  • Verified answer
    Ayushaman Profile Picture
    269 on at

    Waed, 
    The issue is resolved 
      public int64 getLedgerDim(MainAccountNum _mainAccountNum, str _vendorAccountNum, str _businessUnit, str _itemId)
        {
          
          LedgerAccountContract ledgerAccountContract = new LedgerAccountContract();
          DimensionAttributeValueContract dimensionAttributeValueContract;
          List valueContracts = new List(Types::Class);
    
          MainAccount mainAccount = MainAccount::findByMainAccountId(_mainAccountNum);
          ledgerAccountContract.parmMainAccount(mainAccount.MainAccountId);
    
          dimensionAttributeValueContract = DimensionAttributeValueContract::construct('BusinessUnit', _businessUnit);
          valueContracts.addEnd(dimensionAttributeValueContract);
    
         
          dimensionAttributeValueContract = DimensionAttributeValueContract::construct('ItemGroup', _itemId);
          valueContracts.addEnd(dimensionAttributeValueContract);
    
          dimensionAttributeValueContract = DimensionAttributeValueContract::construct('Vendor', _vendorAccountNum);
          valueContracts.addEnd(dimensionAttributeValueContract);
    
       
          ledgerAccountContract.parmValues(valueContracts);
    
          DimensionStorage dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(ledgerAccountContract);
          DimensionAttributeValueCombination dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());
          return dimensionAttributeValueCombination.RecId;
        }
    This is how i solved it .Thanks for your help much appreciated.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans