Programmatically activating custom views

co_netco_net Member Posts: 2
I've defined a couple of views in my PageExtension like the example below. Is there a way to activate a view from (for example) an OnDrillDown trigger that uses Page.Run(...) to open the page with the custom views?
    views
    {
        addlast
        {
            view(Invoicing)
            {
                Caption = 'Invoicing';
                Visible = true;
                SharedLayout = false;
                OrderBy = descending(...);
                Filters = where(...);

                layout
                {
                    // hide
                    modify("Opportunity No.") { Visible = false; }

                    // show
                    modify("Bill-to Customer No.") { Visible = true; }
                    modify("Bill-to Name") { Visible = true; }
                }
            }
        }

Answers

  • DavidJsDavidJs Member Posts: 9
    I dont know if that would work with BC, but the old way could be something like this:

    Create a function on your page like:
    SetVisibility(xOpportunityNo, xBilltoCustomerNo, xBilltoName) [all beeing booleans]
    gOpportunityNo := xOpportunityNo;
    gBilltoCustomerNo := xBilltoCustomerNo;
    gBilltoName := xBilltoName;
    
    Then calling the page OnDrillDown with:
    PageVar.SetVisibility(false, true, true);
    PageVar.Run;
    

    It's not the fanciest code but worked for me before.
    And i hope it works in AL!

  • co_netco_net Member Posts: 2
    Yeah i did something like this already as a temporarily hack, so in the page the correct columns/filters are set. But the custom view is not selected/bold, so still a bit unclear for the user this view is now active.

    I hoped for something to do CurrPage.ActivateView() or <viewname>.Enable, but i cant find anything like this.
  • DavidJsDavidJs Member Posts: 9
    Well, there is the option to set the same variable as enabled too.
    Also there is the property "AccessByPermission" but I haven't used this for just a field. So I dont know if it will hide it definitely or just pop an error when the user open the page.
Sign In or Register to comment.