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 :
Finance | Project Operations, Human Resources, ...
Answered

How to get caller form from a class, which is a caller of another form?

(0) ShareShare
ReportReport
Posted on by 133

Hi all,

I have to put a validation on a button's click method, so here is the issue I'm facing.

The button is on "VendPaymProposalEdit" form(child form), let's call it form A. It's caller is a class, which is "CustVendPaymProposalEditForm". And the class opens when I click on a button on the form "LedgerJournalTransVendPaym"(parent form), let's call is form B.

Here, form B is parent and form A is a child form.

Form B(Parent) -> Class -> Form A(Child)

So I need dataSource of Form B on Form A. But there is a class in between, which becomes the caller for Form A.

I hope I didn't confuse you, but is this possible to get datasource/record of caller form form B?

 nmaenpaa , can you help me with this?

I have the same question (0)
  • Alex VN Profile Picture
    1,994 on at

    Hi,

    Can you try to use:

           FormRun             callerForm = element.args().caller();

    To see if this will help to return the callerForm or not? Sorry I don't have machine access now.

  • Bhagyashree Dave Profile Picture
    133 on at

    Hi,

    Yes, I tried that, but it gets the class which is in between of both the forms.

    I don't get the parent form.

    Do you know any other way to get the parent form from the class??

  • Sangram Shinde Profile Picture
    2,114 on at

    Hi Bhagyashree,

    It looks you are trying to add validation on 'Create payments' button from vendor payment proposal form.

    Can you elaborate a bit about requirement, what validation you need to add on button click.

    Regards,

    Sangram

  • Bhagyashree Dave Profile Picture
    133 on at

    Hi Sangram,

    Yes I need to add validation on "Create payments" button on Vendor payment proposal form.

    And the validation is based on it's caller form Vendor Payment's "Date" field.

    So, I need "Date" field of Vendor Payments - LedgerJournalTransVendPaym on Vendor payment proposal - VendPaymProposalEdit form. But I'm getting a class(CustVendPaymProposalEditForm) in between which is called by an action menu item(Create payment proposal - VendPaymProposalCreate).

    So what should I do in this case? any suggestions?

  • GirishS Profile Picture
    27,827 Moderator on at

    Hi Bhagyashree,

    Try to pass the called object name of the class using parmObject() method.

    Thanks,

    Girish S

  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Here's a general answer to the question.
    It doesn't matter if you need to get the caller, or the "caller's caller", or objects that are even further away. The mechanics is always exactly the same. You just have to move step by step.

    1. If you're standing on a form, you can get the caller via element.args().caller()

    2. Once you have the caller, and you're now "standing" on it, and you can get the caller of that class as long as this information is available in that class. Perhaps you can get it from _args of the main method, if the class is launched via the main method. Or perhaps you can get it by some other means. Sometimes you can't get it, if the class is called in a way that that doesn't send the caller information. In this case you might need to adjust the class and it's caller so that the caller information will be passed But basically step 1 (getting caller of the form) is not relevant here at all. Finding out the caller of this class is entirely separate question and challenge.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 456 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans