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 :
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 311
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
    95,761 Super User 2025 Season 2 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
    311 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
    326 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,388 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

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,126

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 744 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 674 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans