web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Form Methods

(0) ShareShare
ReportReport
Posted on by 70

I have 2 forms here, when i click on next button in Register dialog form it opens Bank Account Details dialog form. when ok is clicked it should  close both forms . how can i achieve it ?

pastedimage1683191829579v1.pngpastedimage1683191883366v2.png

  • Suggested answer
    GirishS Profile Picture
    27,843 Moderator on at

    Hi,

    You need to call the element.closeOk method on the clicked method of the ok button from bank details form.

    To close the 1st form you  need to get the caller object and call close method.

    public void clicked()
    {
        super();
        element.close();
        FormRun objectForm = element.args().caller();
        objectForm.close();
    }

    Thanks,

    Girish S.

  • gaya3 killy Profile Picture
    70 on at

    what is actually a Objectform is it a current form object ?

    should i replace it with first form name ?

    please explain?

  • Suggested answer
    GirishS Profile Picture
    27,843 Moderator on at

    objectForm is the buffer for FormRun class - You are getting the caller object which is FormRun in your case.

    Caller object is nothing but first form you have opened which called the second form which is bank details form.

    Thanks,

    Girish S.

  • Martin Dráb Profile Picture
    240,900 Most Valuable Professional on at

    No, the current form is 'element'.

    element.args() returns arguments that the the form was called with, and element.args().caller() returns the form that the current form was opened from.

    It would be clearer if the variable had a more descriptive name, such as callerForm.

  • gaya3 killy Profile Picture
    70 on at

    it is closing only the bank form (2nd form),but not registration form (1 form)?

  • GirishS Profile Picture
    27,843 Moderator on at

    Try debugging the code and find out what went wrong and check whether you are getting the caller object.

    Also can you tell me how you are calling the second form from first form? Can you show us the code?

    Generally, the caller object will be assigned in the init method of the form.

    Below code is the standard way of doing.

    Public class FormName extends FormRun
    {
        //declare variable globally.
        FormRun callerForm;
        
        public void init()
        {
            callerForm = element.args().caller();
        }
        
        [Control("Button")]
        Class Ok
        {
            public void clicked()
            {
                element.close();
                callerForm.close();
            }
        }
    }

    Thanks,

    Girish S.

  • gaya3 killy Profile Picture
    70 on at

    im opening the form based on account type selected as below.

    ______________________

    [Control("Button")]

       class NextButton

       {

           /// <summary>

           ///

           /// </summary>

           public void clicked()

           {      

               if(RegistrationTableTmp.AccountType == AccountType::Business)

               {

                   new MenuFunction(menuItemDisplayStr(BusinessAccDlgMI), MenuItemType::Display).run();

               }

               else if(RegistrationTableTmp.AccountType == AccountType::FixedDeposit)

               {

                   new MenuFunction(menuItemDisplayStr(FDAccTypeDlgMI), MenuItemType::Display).run();

               }

               else if(RegistrationTableTmp.AccountType == AccountType::Salary)

               {

                   new MenuFunction(menuItemDisplayStr(SalaryAccDlgMI), MenuItemType::Display).run();

               }

               else

               {

                   // for savings default close

                   RegistrationTableTmp_ds.formRun().close();

               }

              // after entering data in 2 mi close

              // RegistrationTableTmp_ds.formRun().close();

           }

       }

  • GirishS Profile Picture
    27,843 Moderator on at

    You need to pass the caller object which is formRun also. 

    Try passing along with caller object and check. Try calling the form via code like below.

    Before changing the code please debug the code and check whether you are getting a caller object.

    Args    args;
    FormRun formRun;
    Args = new Args(formStr(FormName));
    args.caller(element);
    formRun = New FormRun(Args);
    formRun.init();
    formRun.run();
    formRun.wait();

    Thanks,

    Girish S.

  • gaya3 killy Profile Picture
    70 on at

    can't we access clicked method of button control in form1  in clicked method of button control of form2 ?

  • GirishS Profile Picture
    27,843 Moderator on at

    No that's not possible. You need to get the caller object of form2, and then only you will be able to perform further operations.

    Thanks,

    Girish S.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 528 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 455 Super User 2026 Season 2

#3
CU10121822-0 Profile Picture

CU10121822-0 376

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans