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)

Creating and using a Common Method

(0) ShareShare
ReportReport
Posted on by 85

I need to create a common method to use it in different Grid Field's modified() methods, I should also be able to pass a parameter to the method of string type (AccountCode) and based on this AccountCode, this new method will perform some logic and return a string value. 

This method I should call in JournalVoucher Lines Grid Account field Modified().

Please also tell me where I should create this method in AOT.

If my requirement is not possible with a method, please suggest the right one. Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Naveen5551 Profile Picture
    85 on at
    RE: Creating and using a Common Method

    Thank you Mr.Sohaib, it seems to be worked for me.

  • Verified answer
    5400 Profile Picture
    7,162 on at
    RE: Creating and using a Common Method

    I will suggest please create static method to call from mutiple place. Now you need only LedgerJournalTransDaily UI, in future same method you need other place with same argument. Please create obe static method in ledgerJournalTrans table and call it in required place.

    If you logic related to DB operation, It should be server static,

    Eaxmple:

    Public static str or EDTName methodname(AccountCode _accountCode)

    {

      performyour logic.

    }

    then you can call whereever it is required as below

    public boolean modified()

    {    

    boolean ret;  

    str or EDTname    st;    

    ret = super();        

    st = ledgerJournalTrans ::methodname("PasingStringValue");  

    return ret;

    }

    you can call this method through ledgerJournalTrans :: any place.

    Thanks

    Bhaskar

  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at
    RE: Creating and using a Common Method

    From your requirement it seems you want to write a method which can be called from modified fields on JournalVoucher lines grid. You can override modifiedField() method at table level which is binded with this grid (datasource at form level).

    You can have a look on smmActivities table's method modifiedField(), this method is actually called on every modified field. There you will also see other methods calling within modifiedField() method for some logic. You can get idea from there for your requirement. If you still have any confusion please do let me know.

  • Verified answer
    Sohaib Cheema Profile Picture
    47,732 User Group Leader on at
    RE: Creating and using a Common Method
    public str myMthodName(str _parm1ofStrType)
    {
        str ret;
        ;
        ret = "som processing";
        
        return ret;
    }


    ------------------------------------------------------
    
    
    public boolean modified()
    {
        boolean ret;
        str     varRetStr;
    
        ret = super();
        
        varRetStr = element.myMthodName("PasingStringValue");
    
        return ret;
    }

  • Suggested answer
    Hariharans87 Profile Picture
    3 on at
    RE: Creating and using a Common Method

    You can create a new class and create a method. You can call the newly created method from the form control modified method. (Best approach)

    Example method:

    public Str TestMethod()

    {

    ......

    return returnStr;

    }

    Otherwise (if it is simple logic)

    Please create this method on the form datasource methods section and call from form control modified method.

  • Sohaib Cheema Profile Picture
    47,732 User Group Leader on at
    RE: Creating and using a Common Method

    if methods are used very frequently we do write those in any class such as Global.

    you may create a class named as GloablCustom and you can write widely used customized methods there, as you need to call those frequently.

    despite of that you have to override modified method on grid field, and call logic from GloablCustom

  • Naveen5551 Profile Picture
    85 on at
    RE: Creating and using a Common Method

    Thank you for the quick response.

    I should call it in single form(LedgerJournalTransDaily), so I will create in Form Level method.

    What would be the syntax of the method for passing a parameter?

    and how should I call it in

    \Forms\LedgerJournalTransDaily\Designs\Design\[Tab:Tab]\[TabPage:OverViewTab]\[Grid:overviewGrid]\SegmentedEntry:LedgerJournalTrans_AccountNum\Methods\modified    ?

  • Hariharans87 Profile Picture
    3 on at
    RE: Creating and using a Common Method

    Based on the calling, we can choose

    1. Form level method

    2. Table level method

    If you call this method from a single form, please create form level method else create table level method.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Mea_ Profile Picture

Mea_ 4

#3
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans