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 open form B based on selected tab page in form A

(0) ShareShare
ReportReport
Posted on by

Hi Experts,

I have form A which has multiple tab page namely 1, 2 & 3.

Each tab page has Form part control, which menu item property is set to menuItemB which opens form B.

Requirement is that when form A is opened it should detect which tab page is active and filter data accordingly for form B.

Note form b does not have any DS  and thus unable to use execute query .

Thanks

Mav.

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    You wrote "when form A is opened it should detect which tab page is active and filter data accordingly for form B." - I'm not sure what this means? Form B is not open at this point, right? So what's the requirement?

    When the form is opened, I think that the first tab page is open by default. And whenever user changes the tab, tabChanged method is called. You can override that method to see the original and new tab page, and store this in a variable. So, this is how you can always know the current tab page.

    When user navigates to another form, you can pass any information from A to B. Either by sending it via args when the MenuItemButton is clicked, or by element.args().caller() in form B - this will return you the FormRun of form A, letting you access all properties of the caller form.

    So, at this point you are in form B, and you know what tab page was active in form A, and you can use this info to filter data. 

  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    Is the datasource different between tabs? If so, you can add the buttons to the tab (3 different buttons) and select the datasource property.

    Or you can add normal button (not MenuItem), put records in args with code on clicked and send. (you will have to manually call the second form with x++)(you can active page with getActivePage)

    You said there is no ds on side B. Even if there is no DS, there is something that calculates the data as a result. You can get caller records and you can use it in calculations.

  • Mav Profile Picture
    on at

    @Nikolaos using Tabchange would disable user personalization.

    @Ergun data source is same for all tab button

    Shared below is the form screen cap of formA & form B .

    pastedimage1627480552461v1.png

    Currently trying to get the caller formcontrol name (tab page name) so that in init itself can have some conditional logic based on which it will filter the data on form B.

    Issue is keep getting object reference is not set for below code line #3 or line #4  written at init of form b.

      public void init()
        {
            FormControlName T1    =   element.design().controlName(formControlStr(FormA,TabPage1)).name();         // GET object refrence not set during run time
            FormControlName fcname  = element.args().callerFormControl().name();                                  // GET object refrence not set during run time
           
            #SysSystemDefinedButtons
     
            super();
            
            showListButton  = this.control(this.controlId(#SystemDefinedShowListButton)) as FormCommandButtonControl;
            showListButton.visible(false);  //TODO Check why it is not disabling the button despite debugger showing visible value false for system show list button.
    
    
            info(fcname);
    
            if(fcname == T1)
            {
                this.BuildTree( T1 related enum,100);   
            }
            
           
           Public void buildTree(enum , count of recs to be displayed) // TODO change count of recs hard code to paramtertize i.e. date range etc
           {
           // logic for building tree for form B & populate it in form B tree control.
           }
           
        }
    

    Thanks

    Mav

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    I don't understand what you mean by "Tabchange would disable user personalization." Can you try to explain it in more detail? Also I was talking about tabChanged(). 

    About "Object reference" error, you need to debug and find out what exact detail throws it. I don't see you using element.args().caller() to get the caller FormRun, perhaps you could try that? 

  • Mav Profile Picture
    on at

    Sure, here are the details of why  should we  refrain from overriding tabChanged() or tabChange() as they would disable user personalization.

    docs.microsoft.com/.../enabling-user-personalization-of-forms

    Debugging shows this for formB init() .

    pastedimage1627484650233v1.png

    Not sure why caller is Null when the flow is form A T1 (tab page control) has FP1 (form part) menu item property of which is set to formBmenuitem .

       Form A

    pastedimage1627484865612v2.png             

    Property of above selected form part showing menu item name.

    pastedimage1627484936376v3.png                                                              

    Thanks

    Mav

  • Mav Profile Picture
    on at

    I did some more tshooting & debugging & realize that xArgs at form B init() has null value for caller & hence we were getting null.

    Xargs  does have menuitemname value as menuitemB . SO wrote below code at form B init() & it infoed menuItemB which is the name of menu item use to open formB.

    Questions

    1>Is there any reason for why there is no caller name but menu item name for xargs at init() of form B.

    2>Using menuitemB , how can i set formRum callerForm to Form B ,

    pastedimage1627489804438v1.png

    Thanks

    Mav

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    1) You have to look back the call stack to find it out. Perhaps you call this menu item via code, and don't set any caller in the Args object. Just the first guess that comes in mind.

    2) You can't get the caller form unless the caller passes it. With normal MenuItemButton it happens automatically, but if you wrote some code to call the menu item, it's your responsibility to define the caller in the Args object

  • Mav Profile Picture
    on at

    There is no code written anywhere to call menuitemB which opens form B.

    The flow is via GUI only & it is like

    1>User opens Form A

    2>Form A itself loads a default tab page.

    3>The tab page has form part control

    4>The form part control has menuitem property set to menuitemB

    As there is no code for loading menuitemB (also verfied by find refrences & found none) , the call stack shows nothing important.

    Thanks

    Mav.

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

    I think the key here is that form B is a form part, not a normal form.

    This blog might help you to get the caller: www.agermark.com/.../difference-between-local-and-remote.html

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 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans