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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Clear Customized Field based on AccountType

(0) ShareShare
ReportReport
Posted on by 85

We already have standard functionality that clears the AccountCode, when modified the AccountType in Journal Voucher lines.

I have tried the below at \Forms\LedgerJournalTransDaily\Designs\Design\[Tab:Tab]\[TabPage:OverViewTab]\[Grid:overviewGrid]\ComboBox:LedgerJournalTrans_AccountType\Methods\modified,

if(this.selection() != LedgerJournalACType::Ledger)
{
LedgerJournalTrans.LedgerAccountName = "";
}

This is not working in some scenarios, so I think I should write the code, where standard function clearing the AccountCode automatically when modified.

I think here, \Forms\LedgerJournalTransDaily\Data Sources\LedgerJournalTrans\Fields\OffsetAccountType\Methods\modified

In method: ledgerJournalEngine.offsetAccountTypeModified

But unable to write anything here.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    5400 Profile Picture
    7,162 on at
    RE: Clear Customized Field based on AccountType

    Please write a code here.

    \Forms\LedgerJournalTransDaily\Data Sources\LedgerJournalTrans\Fields\AccountType\Methods\modified

    if (LedgerJournalTrans.AccountType != LedgerJournalACType::Ledger)    

           {

             //blank your field

            LedgerJournalTrans.field = '';

           }

    Same type of code required for  offset accountType scenario.

    Also You can write in below method  same code. If it is required in mutiple form.

    \Classes\LedgerJournalEngine\accountTypeModified
    \Classes\LedgerJournalEngine\offsetAccountModified

  • 5400 Profile Picture
    7,162 on at
    RE: Clear Customized Field based on AccountType

    what scenario is not working.

  • Mariano Gracia Profile Picture
    on at
    RE: Clear Customized Field based on AccountType

    I suggest you to modify accountTypeModified method from LedgerJournalEngine class instead of writing the code in the form, it is a best practice to write the code in the lowest level. I would also use a eventHandler to avoid modifying sys layer

  • Naveen5551 Profile Picture
    85 on at
    RE: Clear Customized Field based on AccountType

    Dear Bhaskar and Gracia,

    Thank you for your replies.

    Please ignore my if condition in my question.

    I should clear the field only if account is modified.

    If I select the same account again it should do nothing, as standard functionality does to AccountCode.

    Im writing the code LedgerJournalTrans.LedgerAccountName = "" in modified method at data source level, but this is clearing everytime even if I select the same account again.

    This should be fixed, hope you got my problem. Please suggest me accordingly.

  • Sohaib Cheema Profile Picture
    48,843 User Group Leader on at
    RE: Clear Customized Field based on AccountType

    you may write another condition with and

    && LedgerJournalTrans.AccountType  != LedgerJournalTrans.orig().AccountType  

  • 5400 Profile Picture
    7,162 on at
    RE: Clear Customized Field based on AccountType

    See if you have to catch your orig value,

    if (LedgerJournalTrans.AccountType  != LedgerJournalTrans.orig().AccountType &&   LedgerJournalTrans.AccountType != LedgerJournalACType::Ledger)

    {

    }

    Note: Why are you doing this customization. LedgerAccountname will be display account name only for ledger. i will suggest please make this field non editable. once you select the account type please create one method which will bring ledger name from main account master and other case it will be blank.

    Please write code in ledgerDimension Field modified method. \Forms\LedgerJournalTransDaily\Data Sources\LedgerJournalTrans\Fields\LedgerDimension\Methods\modified

    if (LedgerJournalTrans.AccountType == LedgerJournalACType::Ledger)

    {

      LedgerJournalTrans.ledgerAccountName = MainAccount::find(DimensionAttributeValueCombination::find(LedgerJournalTrans.ledgerdiemnsion).MainAccount).Name

    }

    else

     

    {

    LedgerJournalTrans.ledgerAccountName = '';

    }

  • Naveen5551 Profile Picture
    85 on at
    RE: Clear Customized Field based on AccountType

    Dear Sohaib,

    The condition is not working.

    It is getting cleared even if I select the same account type.

    Bhaskar, please ignore the condition != LedgerJournalACType::Ledger.

    Also regarding the AccountName, I already written it.

    My problem is only clearing it, when other AccountType is selected.

    If selected same it should do nothing. hope you understand.

  • 5400 Profile Picture
    7,162 on at
    RE: Clear Customized Field based on AccountType

    See in modify method there is no super().

    you have use below logic only. It is there in code already.

    \Forms\LedgerJournalTransDaily\Data Sources\LedgerJournalTrans\Fields\LedgerDimension\Methods\modified

    if (priorAccountType != ledgerJournalACType)

    {

    }

    It should work.

  • 5400 Profile Picture
    7,162 on at
    RE: Clear Customized Field based on AccountType

    can you send detail in screen shot.. what you want.  

  • Naveen5551 Profile Picture
    85 on at
    RE: Clear Customized Field based on AccountType

    I should write logic when AccountType is modified, not when AccountCode is selected.

    So I'm writing in \Forms\LedgerJournalTransDaily\Data Sources\LedgerJournalTrans\Fields\AccountType\Methods\modified.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#1
Community Member Profile Picture

Community Member 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans