Hi, Readers.
Views in Dynamics 365 Business Central are used on list pages to define a different view of the data on a given page. A view offers:
- Filtering on multiple table fields on the source table defined for the page.
- Sorting of the data on multiple table fields, but only in one direction; either ascending or descending.
- Layout changes, modifying page columns, moving them, etc.
When you have set a filter on a list and you want to keep the filter for later, you can save it as a view. More about To save a view in MS Docs.
This is a great feature, but there has always been a problem. No matter how many views you create, or which view you stay on when you close the page, when you open the page again, the All view will be opened by default.
So can we specify the default view? I always thought this was impossible. However, I learned a method in the Dynamics 365 Community last week. In this post, I will briefly share it with you, hoping it will be helpful. More details: Page Predefined Views
First, let me briefly explain why I think it is not possible.
About where are list views saved?
Similarly to hiding a field or reordering your navigation menu, list views are a part of user personalization and are stored in the database. Clearing all personalization on a list will also permanently remove your personal views and clear other personalization such as reordering of views. For more information, see Personalize your workspace.
But in the world of Cloud (SaaS), we cannot directly access the database, so we cannot find this part of the data.
The second problem is that in the Web Client URL, there is no URL Parameters about List View, more details:
Parameter | Description |
---|---|
https | Specifies the Internet protocol to use. Only https is supported. |
hostname | Specifies the hostname for Dynamics 365, for example, businesscentral.dynamics.com . |
<aadtenantid> | Specifies the unique identifier for a Microsoft Entra tenant. The value can be formatted as a GUID or domain name. It’s useful to people who work across multiple Microsoft Entra organizations, such as delegated administrators, support personnel, or external accountants. It allows explicitly targeting a Microsoft Entra tenant. If this parameter is omitted, you’ll be directed to the primary Microsoft Entra tenant or the same Microsoft Entra tenant that you’re currently signed in to. |
<environmentname> | (online only) Specifies the display name of sandbox or production environment to target. |
company | The name of the company in Dynamics 365 that you want to target. If you only have one company, then you can omit this parameter. |
page | Opens a page object. |
query | Opens a query object. Note: The TopNumberOfRows property is ignored when the query opens in the browser. |
report | Opens a report object. |
table | Opens a table object. Opening a table requires special permissions. For more information about opening a table, see Viewing Table Data. |
ID | The ID of the page, report, or table to open. |
tenant | (on-premises only) Specifies the ID of the tenant to connect to. Use this parameter when Web client is deployed in multitenant architecture. The tenant that you specify must be mounted on the Dynamics 365 Business Central service instance that the Web client connects to. For more information, see Multitenant Deployment Architecture. |
mode | Specifies the mode in which to display the page when it opens. Once the page opens, you can switch modes as usual, unless restricted by the page itself. – View The page can only be viewed. The user can’t change data on the page. Note: Worksheet page types only display in the edit mode, even if the value is set to View .– Edit The user can change data on the page. Note: To use the edit mode, the Editable Property of the page in Page Designer must be set to Yes. This mode isn’t supported for pages of the type List, RoleCenter, and CardPart. If you set the value to Edit , pages of these types still display in the view mode. For List type pages, the user can modify the list by choosing Edit List on the page.– Create Opens a blank page that enables the user to create a new item. Note: The Create mode isn’t supported for pages of the type CardPart, List, ListPart, RoleCenter, and Worksheet. For pages of the type CardPart, List, and ListPart, the page displays in the view mode. Don’t use this mode for Worksheet pages; otherwise you’ll get an error when you try to open the page. |
profile | Specifies the ID of the profile to open, such as accountant or order processor .It’s possible for two or more profiles have the same ID. Profiles can have a scope of either system or tenant. Also, tenant profiles can be either user-defined (added by using the Profiles page in the client) or extension-based (added by an extension). Among these different types, the IDs of some profiles might be the same. If there’s more than one profile with the same ID as you provide, the profile is selected as follows:If there’s a matching system profile, it’s used.If there’s a matching user-defined tenant profile, it’s used.If there’s only one matching extension-based profile, it’s used.If there are two or more extensions-based profiles with the same ID, then the error message More than one profile has the ID '<ID>' within the Tenant scope. appears. In this case, you can’t use the profile parameter for this profile. |
customize | Opens the profile for customization, enabling you to change the layout of pages as seen by users of the profile. If you omit the profile , then the default profile opens. For more information, see Customizing the Workspace for Profiles (Roles) in the Business Central Application Help. |
bookmark | Specifies a record in the underlying table of the page. The value of a bookmark is an alphanumeric string of characters, for example, 27%3bEgAAAAJ7CDAAMQA5ADAANQA4ADkAMw%3d%3 .For the page types Card, CardPart, and Document, the bookmark specifies the record that is shown in the page. For page types List, ListPart, and Worksheet, the bookmark specifies the record that is selected in the list on the page. Important: Bookmarks are generated automatically. You can only determine a value for the bookmark by displaying the page in the Web client and looking at its address. So, a bookmark is only relevant when the address you’re working with was copied from another page instance. |
captionhelpdisabled | Specifies that the ability to look up Help by selecting a field caption is disabled. If you want the Help look up from the field captions, either omit this parameter or set its value to 0 , such as captionhelpdisabled=0 .If you don’t want the Help lookup from field captions, set the value to 1 , such as captionhelpdisabled=1 .Note: For this parameter to take effect, add it at the first request when the user signs in. Adding the parameter on an existing session has no effect. |
showribbon | Specifies whether to show the action bar on pages when they open. To show the action bar, omit this parameter or use showribbon=1 . To hide the action bar, use showribbon=0 .When you hide the action bar, it will remain hidden as you move to different pages, until you refresh or reload the browser or use showribbon=1 in the URL. Once you move to another page, the parameter is no longer shown in the URL, even though it’s still in effect. |
shownavigation | Specifies whether to show the navigation bar when the specified page opens. To show the navigation bar, omit this parameter or use shownavigation=1 . To hide the navigation bar, use shownavigation=0 .When you hide the navigation bar, it will remain hidden as you move to different pages, until you refresh or reload the browser or set shownavigation=1 in the URL. Once you move to another page, the parameter is no longer shown in the URL, even though it’s still in effect. |
showuiparts | Specifies whether to show UI parts when the specified page opens. To show parts, omit this parameter or use showuiparts=1 . To hide parts, use showuiparts=0 .This parameter only affects parts that are shown in FactBoxes. Once you move to another page, the parameter is cleared. |
showheader | Specifies whether to show the Dynamics 365 Business Central header and its functionality. (This was introduced in Business Central 2020 release wave 1, update 16.2.) The header is the bar at the top of pages. It gives access to the general functionality like Tell Me, Notifications, My Settings, and more. To show the header, omit this parameter or use showheader=1 . To hide the header, use showheader=0 .When hidden, functionality that has a keyboard shortcut, like Tell Me, is still accessible by the shortcut. The parameter is preserved when you move to other pages and if you refresh or reload the browser. Note: The help pane isn’t available when the header is hidden. Selecting Ctrl+F1 opens a Business Central help article on Microsoft Docs instead of the help pane. |
isembedded | Specifies to open the Business Central Web client in the embedded mode. To set the embedded mode, use isembedded=1 .This parameter is intended for use when Business Central Web client is embedded in another web application, like SharePoint. The embedded mode hides the Dynamics 365 Business Central header and adjusts how navigation works to suit the web application. For more information, see Embedding Business Central Web Client in Other Websites. Note: The help pane (Ctrl+F1) and company switcher (Ctrl+O) aren’t available in the embedded mode. Selecting Ctrl+F1 opens a Business Central help article on Microsoft Docs instead of the help pane. |
pagesize | Specifies the number of lines to display in a list. For example, pagesize=10 specifies that 10 lines will be displayed. The default value, if the parameter isn’t specified, is 20 The parameter applies only to pages that contain a repeater control. It’s intended for use when Business Central Web client is embedded in another web application, like SharePoint. For more information, see Embedding Business Central Web Client in Other Websites. |
redirect | Specifies whether users are presented with an option to download the Business Central Mobile App when they open the Web client in a mobile browser to improve the user experience. If you don’t want to give users this option, set the value to 0 , such as redirect=0 . |
extension | Specifies the unique identifier (ID) of an extension that is deployed on the environment. This parameter is typically used during the development of the specified extension in a non-production environment. When this parameter is set, only the specified extension is available in the client, and the client opens in Designer. All other extensions are ignored and not visible. This parameter enables you to isolate and focus on the behavior of the specified extension only. An extension ID is a 32-digit GUID, such as 72CC5E27-BD97-4271-AF55-F77E4471E493 . You set this parameter using the format extension={GUID} , for example:&extension={72CC5E27-BD97-4271-AF55-F77E4471E493} You can determine an extension ID by opening the extension in Visual Studio Code and looking in the app.json file. Or, you can run the Get-NAVAppManifest cmdlet on the extension package. |
PS: Dynamics 365 Business Central: Filtering Data by the Web Client URL
So I think this can’t be done, but in fact the Web Client URL contains the “view” parameter. (Version: W1 23.4 (Platform 23.0.16474.0 + Application 23.4.15643.15715))
Let’s see a few examples,
Item List (31, List):
All (Default view): No “view” parameter.
https://businesscentral.dynamics.com/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox234?company=My%20Company&page=31&dc=0&bookmark=13_GwAAAAJ7BDEAMAAwADM
Test01:
https://businesscentral.dynamics.com/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox234?company=My%20Company&view=aa49406f-6f68-4565-b857-496faa0e77aa_Test0112223&page=31&filter=Item.%27No.%27%20IS%20%271800-S..1900-S%27&dc=0&bookmark=17_GwAAAAJ7_zEAOAA5ADYALQBT
Test02:
https://businesscentral.dynamics.com/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox234?company=My%20Company&sk=SxsB0m7JFXprxyf74oyPTw&view=aa49406f-6f68-4565-b857-496faa0e77aa_Test0221625&node=0000233e-fd3e-0000-0c46-0f00836bd2d2&page=31&filter=Item.%27No.%27%20IS%20%271900-S..%27&dc=0&bookmark=17_GwAAAAJ7_zEAOQAwADAALQBT
ZYTest:
https://businesscentral.dynamics.com/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox234?company=My%20Company&sk=SxsB0m7JFXprxyf74oyPTw&view=aa49406f-6f68-4565-b857-496faa0e77aa_ZYTest00045&node=0000233e-fd3e-0000-0c46-0f00836bd2d2&page=31&filter=Item.Inventory%20IS%20%27%3e0%27&dc=0&bookmark=17_GwAAAAJ7_zEAOAA5ADYALQBT
Customer Ledger Entries (25, List):
Invoice:
https://businesscentral.dynamics.com/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox234?company=My%20Company&sk=SxsB0m7JFXprxyf74oyPTw&view=aa49406f-6f68-4565-b857-496faa0e77aa_Invoice07400&page=25&filter=%27Cust.%20Ledger%20Entry%27.%27Document%20Type%27%20IS%20%272%27&dc=0&bookmark=C_FQAAAACHqQY
Payment:
https://businesscentral.dynamics.com/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox234?company=My%20Company&sk=SxsB0m7JFXprxyf74oyPTw&view=aa49406f-6f68-4565-b857-496faa0e77aa_Payment57019&page=25&filter=%27Cust.%20Ledger%20Entry%27.%27Document%20Type%27%20IS%20%271%27&dc=0&bookmark=C_FQAAAACHgAY
PS:
1. If the view name contains characters that cannot be recognized by the web browser, they will be automatically encoded.
More details: Dynamics 365 Business Central: How to encode and decode URL/HTML (UrlEncode, UrlDecode, HtmlEncode, and HtmlDecode)
https://businesscentral.dynamics.com/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox234?company=My%20Company&sk=SxsB0m7JFXprxyf74oyPTw&view=aa49406f-6f68-4565-b857-496faa0e77aa_Payment%20%5bCopy%5d13152&page=25&filter=%27Cust.%20Ledger%20Entry%27.%27Document%20Type%27%20IS%20%271%27&dc=0&bookmark=C_FQAAAACHgAY
2. Even if you rename the view on the page, the original name is still saved in the URL. So the view ID will not change.
3. We can use the following URL to directly open the specified view.
https://businesscentral.dynamics.com/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox234?company=My%20Company&view=aa49406f-6f68-4565-b857-496faa0e77aa_Test0112223&page=31
Test video: So you only need to ask the customer to open BC from the URL, so that the required view can be opened directly.
Here are some additional conclusions
1. The id of each view is fixed (The view must be opened first to get the id from the URL)
2. It consists of the “Page id” + “_” + “View Name” + “Random five numbers”
3. The “Page id” of each page is the same
So if customized, we can simply do the following.
Test video: This method is to open a new tab.
Source code: Github (Please note that the source code is for reference only, you can improve it according to your own needs)
pageextension 50120 CustomerListExt extends "Customer List"
{
actions
{
addafter(ApplyTemplate)
{
action("Item list - Test01")
{
ApplicationArea = All;
Caption = 'Item list - Test01';
Image = Open;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
OpenSpecifiedView('aa49406f-6f68-4565-b857-496faa0e77aa_Test0112223', Page::"Item List");
end;
}
action("Item list - Test02")
{
ApplicationArea = All;
Caption = 'Item list - Test02';
Image = Open;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
OpenSpecifiedView('aa49406f-6f68-4565-b857-496faa0e77aa_Test0221625', Page::"Item List");
end;
}
action("Item list - ZYTest")
{
ApplicationArea = All;
Caption = 'Item list - ZYTest';
Image = Open;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
OpenSpecifiedView('aa49406f-6f68-4565-b857-496faa0e77aa_ZYTest00045', Page::"Item List");
end;
}
action("Customer Ledger Entries - Invoice")
{
ApplicationArea = All;
Caption = 'Customer Ledger Entries - Invoice';
Image = Open;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
OpenSpecifiedView('aa49406f-6f68-4565-b857-496faa0e77aa_Invoice07400', Page::"Customer Ledger Entries");
end;
}
}
}
local procedure OpenSpecifiedView(ViewID: Text; PageID: Integer)
var
DefaultView: Text;
URL: Text;
begin
DefaultView := '&view=' + ViewID;
URL := GetUrl(CurrentClientType, CompanyName, ObjectType::Page, PageID) + DefaultView;
Hyperlink(URL);
end;
}
If you need to open in the same window/current session, consider the following solution, which is a little more complicated.
Dynamics 365 Business Central: Using Hyperlink() Method to open a URL in a current session without opening a new tab in the browser
Test video:
Source code: Github (Please note that the source code is for reference only, you can improve it according to your own needs)
pageextension 50120 CustomerListExt extends "Customer List"
{
actions
{
addafter(ApplyTemplate)
{
action("Item list - Test01")
{
ApplicationArea = All;
Caption = 'Item list - Test01';
Image = Open;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
OpenSpecifiedView('aa49406f-6f68-4565-b857-496faa0e77aa_Test0112223', Page::"Item List");
end;
}
action("Item list - Test02")
{
ApplicationArea = All;
Caption = 'Item list - Test02';
Image = Open;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
OpenSpecifiedView('aa49406f-6f68-4565-b857-496faa0e77aa_Test0221625', Page::"Item List");
end;
}
action("Item list - ZYTest")
{
ApplicationArea = All;
Caption = 'Item list - ZYTest';
Image = Open;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
OpenSpecifiedView('aa49406f-6f68-4565-b857-496faa0e77aa_ZYTest00045', Page::"Item List");
end;
}
action("Customer Ledger Entries - Invoice")
{
ApplicationArea = All;
Caption = 'Customer Ledger Entries - Invoice';
Image = Open;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
OpenSpecifiedView('aa49406f-6f68-4565-b857-496faa0e77aa_Invoice07400', Page::"Customer Ledger Entries");
end;
}
}
}
local procedure OpenSpecifiedView(ViewID: Text; PageID: Integer)
var
DefaultView: Text;
URL: Text;
ZYHyperLink: Page "ZY HyperLink";
begin
DefaultView := '&view=' + ViewID;
URL := GetUrl(CurrentClientType, CompanyName, ObjectType::Page, PageID) + DefaultView;
ZYHyperLink.SetURL(URL);
ZYHyperLink.Run();
end;
}
page 50111 "ZY HyperLink"
{
Extensible = false;
Caption = 'HyperLink';
Editable = false;
PageType = Card;
layout
{
area(content)
{
group(Control5)
{
ShowCaption = false;
}
usercontrol(WebPageViewer; "Microsoft.Dynamics.Nav.Client.WebPageViewer")
{
ApplicationArea = All;
trigger ControlAddInReady(callbackUrl: Text)
begin
CurrPage.WebPageViewer.Navigate(URL);
end;
trigger Callback(data: Text)
begin
CurrPage.Close();
end;
}
}
}
var
URL: Text;
procedure SetURL(NavigateToURL: Text)
begin
URL := NavigateToURL;
end;
}
Great, give it a try!!!😁
END
Hope this will help.
Thanks for reading.
ZHU
コメント