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

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

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 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,827 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
    237,884 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,827 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,827 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,827 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

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
Martin Dráb Profile Picture

Martin Dráb 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans