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?