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)

Retrieve name of object that called a form.

(0) ShareShare
ReportReport
Posted on by

Hello,

We have a form that we would like to customize based on what object calls it. How after a form is called can we see the name of the object that called it? Not finding a lot of direction on this but surely it must be possible because when running through the debugger I can see the parent objects names. 

Thanks!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Ivan (Vanya) Kashperuk Profile Picture
    on at

    In init method on the form, you can access it through

    element.args().caller()

    You can take a look at Classes\SysTableLookup\getCallerStringControl() for an example of how to handle different types of callers

    In order to get the name of the form calling it, you could assign it to a variable of type FormRun, as shown in the above example

  • Community Member Profile Picture
    on at

    Thanks so far I am having no luck though. The data I am trying to get is the name value here. So far I am unable to work out the proper reference to get that name.

    NAME:

    ELEMENT.callerForm.dialogObj.caller

    VALUE:

    new, CUSTOMCustAgingReportController

    TYPE:

    Object

  • Andrew Xu Profile Picture
    3,877 on at

    Try "element.args().callerFormControl().name()" to see if that's what you want.

  • Community Member Profile Picture
    on at

    Negatory. This got me an error. I guess in the particular case I am working on I need the Class or the Menu item that called the form that the control is on. The closest thing I can explain it as is the Customer Aging form, we have a custom version that has the Sales Rep avalible as a filter, this is handled by a dropdown on the form that calls HCMWorkerLookup which gives them the opportunity to choose a rep. It is from the HCMWorkerLookup form that I want to find what called itself. So in this case it would be the output menu item CustomCustAgingBalance called the CustomCustAgingReportController class and that is what launched the dialog. I need the name CustomCustAgingReportController while in the HCMWorkerLookup  so that I can ascertain if the HCMWorkerLookup should apply specific filters only needed for that instance.

  • Suggested answer
    Ivan (Vanya) Kashperuk Profile Picture
    on at

    element.args().caller() will in this case return you the dialog form which had the control.

    You need to assign this to a variable of type "Object" to skip the compile validation of method existence - I assume that on this dialog of yours there is a method called "callerForm" or dialogObj

    Object dlgFrm;

    Object (potentially this could be Dialog class) dlg;

    Object controller;

    dlgFrm = element.args().caller();

    dlg = dlg.dialogObj();

    controller = dlg.caller();

    the type of the controller in this case should be CUSTOMCustAgingReportController, if I understood your description right.

  • Andrew Xu Profile Picture
    3,877 on at

    If you get an error, then try,

       Form tempForm;

       tempForm = element.args().caller();

       if (tempForm != null)

       {

           tempForm.name();

       }

  • OrangeRocks Profile Picture
    700 on at

    Hej,

    what about if I want to define my caller from a table method and not from a Form?

    An element.args().caller would work only in a form.

    If I want to know the caller from a table method, then i would probably need  args() as an argurment to that method, right?

  • Mea_ Profile Picture
    60,284 on at

    Hi Pam,

    You can get args using something like this

    if (this.isFormDataSource())

    {

       this.dataSource().formRun().args();

    }

  • OrangeRocks Profile Picture
    700 on at

    Thanks,

    it won't work for tables though. The debugger won't go into the condition. I am using it in a table method

  • Mea_ Profile Picture
    60,284 on at

    Can you please elaborate you question ?

    If this.isFormDataSource() is false that means that table is not a form data source.  So I assume that you are calling table method from a form. However tables does not have "args" so you cannot get a caller, you have to pass it explicitly as a parameter.

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