Search code examples
objectdialogaxaptadynamics-ax-2012x++

How to manage methods\variables caller class?


in class standard class Dialog exist an Object declare (in classDeclaration)

Object caller;

In this class I'm able to get the caller class name. For example:

if (caller.name() == classStr(MyCallerClass) )
{
     // manage-pass variable in caller class
}

If I catch in the IF, I want to pass a parameter in parm method in to MyCallerClass.

How I can pass a simple parameter? For example:

if (caller.name() == classStr(MyCallerClass) )
{
     // MyCallerClass.myParmMethod(parameter);
}

Thanks.


Solution

  • Just call the method:

    if (caller.name() == classStr(MyCallerClass))
        caller.myParmMethod('abc');
    

    As caller is of type Object the compiler accepts any method name, it uses duck typing. A run time error happens if caller does not have the method.

    That said, you should not change the standard Dialog class. You might extend the class, though this is unlikely to be the right thing.

    What you should do depends on information you do not give.