1
votes

I have created a ListPage form, and placed a button. If this button is clicked I want to run a method. I am aware i can't overwrite methods in a ListPage form, therefore I want to create a method on a table which the form is using.

So, i need to check if the button is clicked from the table method, how can i accomplish is?

I have tried to create a method with:

MenuItem.clicked();

But i am not sure how to declare MenuItem so .clicked(); is recognized. How can i accomplish this?

1
Wait, you want to "click" the menu item from the table method? And then the menu item should run another method? How do you want to trigger the table method in the first place? This sounds confused, maybe you could tell us a bit more about the actual problem you are trying to solve? Also did you take a look at how other buttons of ListPages work? - FH-Inway

1 Answers

2
votes

It sounds like you want to have a button on a listpage "do" something. A pattern you should get into is creating a class to hold your code/logic, then referencing it via menu-item.

Create a class (MyClass) with a main method like this:

static void main (Args _args) 
{ 
    // Your X++ code here. 
}

Then create an action menu item with the ObjectType = Class and Object = MyClass.

Add that action menu item to the listpage and it should allow you to trigger code. The _args is how you can pass data to your MyClass and also reference back to the form if you want. You'll likely want to set the DataSource property on the menu item on the list page so you can have the record via _args.record().