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 :
Small and medium business | Business Central, N...
Suggested Answer

Create a custom view and make it the default view

(1) ShareShare
ReportReport
Posted on by 362
Hello!
I would like to create a custom view to my Sales Quotes page. I fiddled around with it, and used the OnOpenPage trigger to set a filter on the page to display the Sales Quotes that are connected to the current logged in user. This is my trigger:
 
trigger OnOpenPage()
    begin
        User.SetRange("User Name", UserId);
        if User.FindFirst() then begin
            SalesPerson.SetRange(Name, User."Full Name");
            if SalesPerson.FindFirst() then begin
                Quotes.SetFilter("Salesperson Code", SalesPerson.Code);
                CurrPage.SetTableView(Quotes);
            end;
        end;
    end;
 
 
When I finished, I figured it would be a much better solution to create a view instead, so I went back to my pageextension and made this:
 
views
    {
        addlast
        {
            view(MyQuotes)
            {
                Caption = 'My Sales Quotes';
                Filters = where ("Salesperson Code" = filter (= "CURRENT LOGGED IN SALESPERSON")))
            }
        }
    }
 
But I can't for the life of me figure out how I can filter with a variable, or if that is even possible. 
 
I tried creating global variables to store the current User and SalesPerson, in hopes I could use it in the view, but I struggle a bit with this one, to be honest.
 
Is there any way to create a view in AL that filters the Quotes with the filter I want, and is it possible to make it the default view for the page?
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    99,084 Super User 2026 Season 1 on at
    This can be associated with fields, but not with variables.
    For default view: Dynamics 365 Business Central: How to set the default view/layout for a list page (Predefined List View)
     
    Hope this helps.
    Thanks.
    ZHU
  • Hagru Profile Picture
    362 on at
    So in reality there is no way to get the current logged in user, and find their SalesPerson code, and create a view for it the way I would've liked here?
  • Suggested answer
    Andy Wingate Profile Picture
    328 on at
    Hello 
     
    "So in reality there is no way to get the current logged in user, and find their SalesPerson code, and create a view for it the way I would've liked here?"
     
    Yes you can - if you take a mix of the soluton from Yun Zuh  - i.e. ask users to click a URL that will open a specific view.
     
    AND 
     
    you set your salesperson codes to be the same as the user.name of the sellers
     
    AND
     
    create a filter view where you set the Salesperson Code = %user


     

     
    %user% always resolves to the logged in user, so thats why you need to match up usernames and sales person codes
     
     
    The only issue you might have is if you have very long usernames!
     
    Hope this helps
     
    Andy
     
     
  • Gerardo Rentería García Profile Picture
    25,555 Most Valuable Professional on at
    Hi
    (%me or %user) Records Assigned to You
    Best
    GR

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,946 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,177 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 555 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans