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 :
Microsoft Dynamics AX (Archived)

Calling method from tab to init

(0) ShareShare
ReportReport
Posted on by

Here I am once again,
Calling a method in the same object is easy, calling it from one form to another one is explained in gazillion tutorials and posts.
I have form with tab inside and two other tabs inside that.
I was trying to implement some caller, but I'm doing something wrong.

Method I want to call is a part of listView, lets name is MyListView, on the tab and I'm using it to populate it.

public void MethodToCall()
{}

I'm trying to deploy it during form opening so:

void Init()

{

object caller = new object();

;

caller.MethodToCll(); //there is nothing like it inside caller object.

}

Is there any other way to run this method from another, or call MyListView from init level?

init method does not recognize any other method but those directly in form, "on the same level".

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,908 Most Valuable Professional on at

    Do I understand correctly that you're talking about tabs on the same form? Than you don't need any with any caller, just references inside the same form. Nevertheless if you want to work with a caller from another form, you should read one of gazillion tutorials and posts, because you're doing it wrong.

  • Community Member Profile Picture
    on at

    Bez_A000_tytu_4201_u.jpg

    More than 100 Words.

  • Jonathan  Halland Profile Picture
    11,310 on at

    I understand you are basically wanting to call a method on a ListPage (list view?) type of form from a child form. You would need to do so via the caller's listpage interaction class not directly as you are wanting to do.

  • Jonathan  Halland Profile Picture
    11,310 on at

    Sorry for my misunderstanding.

    Why can you not move that method to the BomCompareForm's method node instead of being inside the listview?

  • Suggested answer
    Martin Dráb Profile Picture
    237,908 Most Valuable Professional on at

    You can set AutoDeclaration property of any control to Yes and then refer to its name in X++.

  • Community Member Profile Picture
    on at

    Because I couldn't use the listView anywhere outside itself. I can't find any information how to do it. Instead I have found tutorials about calling methods from one form to another using caller. Thinking it would be similar I start to deploy my idea, but it wasn't.

    At the weekend I'll have more time to get familiar with books about dynamics, at this point is a dark magic for me.

  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at

    As per Martin's suggestion, you really just need to change your perspective. You can access all the properties of control that you need from outside of the control itself as long as you declare it as "AutoDeclaration".  Then declare your method on the form itself and call InventListView.[controlsmethod] from inside it

  • Community Member Profile Picture
    on at

    Is already set to "Yes". I'm doing it wrongly in code. I made FillListByProperties as static, but then I cant use "this" word, what is the only way (only I know) to work on my ListView. Otherwise InventListView is invisible even inside its own method.

  • Verified answer
    Martin Dráb Profile Picture
    237,908 Most Valuable Professional on at

    The whole nature of static methods is that they're not associated with any instance, therefore it makes no sense in your case. Use an instance method instead.

    Also adding static methods to form controls is useless, because form controls are not types and you would need the type name to call your static method. So you would have no way how to call such a method.

  • Verified answer
    Anton Venter Profile Picture
    20,346 Super User 2025 Season 2 on at

    Hi, refactor your code. Move the code in the fillListByProperties method up to the "form level". You will then be able to call the method from the form's init method. Code calling the original method can then be changed to element.fillListByProperties();

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans