Edit Method D365 for a form Data Source
1. To create an edit method first create a controller class. with following properties
{
MainAccountNum accountId = _id;
MainAccount mainAccount = MainAccount::findByMainAccountId(_id);
if(_set)
{
if(_ledgerjournal.AccountType== LedgerJournalACType::Ledger)
{
mainAccount = MainAccount::findByMainAccountId(accountId);
if(_ledgerjournal.LedgerDimension)
{
DimensionDefault defaultDim = LedgerDimensionFacade::getDefaultDimensionFromLedgerDimension(_ledgerjournal.LedgerDimension);
_ledgerjournal.LedgerDimension = LedgerDimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(mainAccount.RecId,
DimensionHierarchy::getAccountStructure(mainAccount.RecId),
defaultDim);
}
else
{
_ledgerjournal.LedgerDimension = LedgerDimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(mainAccount.RecId,
DimensionHierarchy::getAccountStructure(mainAccount.RecId));
}
}
}
else
{
accountId= MainAccount::find(DimensionAttributeValueCombination::find(_ledgerjournal.LedgerDimension).MainAccount).MainAccountId;
}
return accountId;
}
3. Create a field of String or Int64 and call this edit method in its Data method and add Data source for which it is created
HEY HEY HEY !!! HACK OF THE DAY !!!
Always use return type of edit method same as the type of field in a form in which you will call edit method.
Comments
Post a Comment