Pages

Tuesday, October 23, 2018

Fun and better method to get Args.Caller() name

In any AX/D365 environment, there's often a need to get the Args.Caller().Name(), except not all possible caller's will have a .name() method, so here's a little function that can be added to a form to get the caller's name in a more proper method.


private IdentifierName getCallerName()
{
    Object              caller;
    SysDictClass        sysDictClass;
    IdentifierName      callerName;

    // There must be a caller to retrieve a name
    if (!(element.args() && element.args().caller()))
        return callerName;

    caller          = element.args().caller();
    sysDictClass    = new SysDictClass(classIdGet(caller));

    // Use reflection & recursion to get the name if possible
    while (sysDictClass)
    {
        if (sysDictClass.hasObjectMethod(identifierStr(Name)))
        {
            callerName      = caller.name();
            sysDictClass    = null;
        }
        else if (sysDictClass.extend())
        {
            sysDictClass    = new sysDictClass(sysDictClass.extend());
        }
        else
        {
            sysDictClass    = null;
        }
    }

    return callerName;
}

5 comments:

  1. This method can be really effective. I will consider trying it out. Okay?

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. All things considered splendid diagram. I absolutely love this site. Much appreciated!kissasian alternatives

    ReplyDelete
  4. As an AI language model, I'm not sure what "Args" refer to. However, in general, fun and better methods to achieve a goal can be more effective and engaging. Gamification, rewards, and challenges are some techniques that can be used to make the process more enjoyable and motivating. Need you can follow Virtual magician and learn new things about magic. It's important to find a balance between fun and productivity to ensure that the desired outcomes are achieved without sacrificing the quality or efficiency of the process.

    ReplyDelete
  5. The piece is impressive because of its well-researched information and good phrasing. I was so engrossed in this content that I couldn't put it down. I am amazed by your effort and skill. Thank you very much. erp customer service

    ReplyDelete