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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Initialize LedgerDimension without Main account

(0) ShareShare
ReportReport
Posted on by 114

Hello,

I have a requirement where some dimensions should be automatically initialized when creating a record (from args)

I have a Contract form and then user opens new form and based on the contract Id, contract dimension should be filled 

 

The issue is that I don't want Main account to be filled, the user should manually select it in this segmented entry control.

This is my code:

 LedgerAccountContract                   ledgerAccountContract;
List                                    valueContractList;
DimensionAttributeValueContract         dimContract, dimBuilding;

parameters                              = PMCParameters::find(); 
contDimRecId                            = parameters.ContractDimensionAttribute;
buildingDimRecId                        = parameters.BuildingDimensionAttribute;  
contractDimensionName                   = DimensionAttribute::find(contDimRecId).DimensionKeyColumnName;
buildingDimensionName                   = DimensionAttribute::find(buildingDimRecId).DimensionKeyColumnName;
ledgerAccountContract                   = new LedgerAccountContract();
valueContractList                       = new List(Types::Class);

if (_contract)
{
    dimContract = new DimensionAttributeValueContract();
    dimContract.parmName(contractDimensionName);
    dimContract.parmValue(_contract);
    valueContractList.addEnd(dimContract);
}
if (_buildingId)
{
    dimBuilding = new DimensionAttributeValueContract();
    dimBuilding.parmName(buildingDimensionName);
    dimBuilding.parmValue(_buildingId);
    valueContractList.addEnd(dimBuilding);
}

ledgerAccountContract.parmMainAccount('');
ledgerAccountContract.parmValues(valueContractList);
DimensionStorage dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(ledgerAccountContract);
return DimensionAttributeValueCombination::find(dimStorage.save()).RecId;

 

And it works when I provide some hard-coded Main account but when I don't,  I get the error wrong use of a function.

Any ideas how can I achieve this?

Categories:
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    307,176 Super User 2026 Season 2 on at

    Hi DevGirlX,

     

    For the ledger account field type, you will need a main account to let the dimension service know what account structure and related dimensions should be used.

    You can consider polulating the dimension values after a user selected the main account, or split it in a main account field and a default dimension field. 

  • devgirlX Profile Picture
    114 on at

    Is it possible then to have it contract populated in this lookup ? 

    Or at least filtered records by contractId?

  • André Arnaud de Calavon Profile Picture
    307,176 Super User 2026 Season 2 on at

    Hi DevGirlX,

    Can you explain what you mean with your follow up question?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 430 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 368

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 364 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans