how to call a class and class methods into a form in ax 2012 ?

Hi,

I want to call a class and class parm() methods to a form clicked() method…

please give me some Idea with some examples how to do it

Thanks and regards,

Soumya Ranjan

You can call form methods, but it’s risky. The problem is that forms are not types, therefore you can’t call methods in a type-safe manner and maintaining code without any compile-type control is error-prone. It’s much better to move the logic from the form to a class and call the class. If your form contains business logic that needs to be used from other places, it’s a clear indication that the logic doesn’t belong to any form. If you want to do it anyway, look at my blog post Dynamic method dispatch in X++.

I’m ignoring the fact that clicked() is a form control method, not a form method. If you have any business logic in clicked() method, please go and change it now.

Hi Martin,

I want to know how to call the class into a form after moving the codes from Form control method. And also want to how to call the class methods into the same form.

Thanks and regards,

soumya ranjan

Either I already answered your question, or I don’t understand it and you should try to explain it in more details.

So what’s the issue in calling a class method in form?

You need to declare the class and using that object you can call the class methods.

void

{

YourClassName yourClassName;

clicked()

yourClassName.parmmethod();

}