Hi, Readers.
Yesterday someone asked me a question about how to download the source code of some special Query objects. Such as query 2554 “Items By Location”. It was very interesting, so I decided to share it in this post.
First let’s see where these special Query objects are.
Open the Item List page. Choose All.
![](https://yzhums.com/wp-content/uploads/2021/03/image-37-1024x473.png)
Then you can see some lists (Query) like smart lists. Yes, these Query objects are present in many pages now.
![](https://yzhums.com/wp-content/uploads/2021/03/image-38-1024x488.png)
For example: Items By Location
![](https://yzhums.com/wp-content/uploads/2021/03/image-39-1024x491.png)
If you open Page Inspection, you can see some details about the Query.
![](https://yzhums.com/wp-content/uploads/2021/03/image-40-1024x472.png)
Query:
Items By Location (2554)
Extension:
“id”: “0737a5b0-34ce-4e13-b412-5d677dbccade”,
“name”: “_Exclude_Microsoft Dynamics 365 – Smartlist”,
“publisher”: “Microsoft”,
“version”: “17.4.21491.0”
![](https://yzhums.com/wp-content/uploads/2021/03/image-41.png)
First of all, these query objects cannot be found inside Base Application and System Application.
![](https://yzhums.com/wp-content/uploads/2021/03/image-42.png)
![](https://yzhums.com/wp-content/uploads/2021/03/image-43.png)
It cannot be found in the On-Premises installation package either.
![](https://yzhums.com/wp-content/uploads/2021/03/image-36.png)
So how to download the source code?
There are two ways.
1. Add new dependency to app.json in VS Code.
From Page Inspection, you can get all the information about “_Exclude_Microsoft Dynamics 365 – Smartlist” extension.
So add them to app.json file.
{
"id": "0737a5b0-34ce-4e13-b412-5d677dbccade",
"name": "_Exclude_Microsoft Dynamics 365 - Smartlist",
"publisher": "Microsoft",
"version": "17.4.21491.0"
}
![](https://yzhums.com/wp-content/uploads/2021/03/image-49.png)
Redownload symbol files. Then you will see that the “Microsoft__Exclude_Microsoft Dynamics 365 – SmartList_17.4.21491.21867.app” file has been downloaded.
![](https://yzhums.com/wp-content/uploads/2021/03/image-50-1024x543.png)
![](https://yzhums.com/wp-content/uploads/2021/03/image-51-1024x548.png)
After unzipping the app file, you can get all the source code.
![](https://yzhums.com/wp-content/uploads/2021/03/image-52-1024x721.png)
![](https://yzhums.com/wp-content/uploads/2021/03/image-53-1024x663.png)
2. Get to the source code of the default apps by Business Central Artifacts
The prerequisite is that the BcContainerHelper must already be installed.
![](https://yzhums.com/wp-content/uploads/2021/03/image-54.png)
Run the following command in Windows PowerShell ISE.
For example: Download the source code of the latest available version.
Download-Artifacts -artifactUrl (Get-BCArtifactUrl) -includePlatform
![](https://yzhums.com/wp-content/uploads/2021/03/image-55.png)
Download Start.
![](https://yzhums.com/wp-content/uploads/2021/03/image-56.png)
Download completed. (About 3-10 minutes)
![](https://yzhums.com/wp-content/uploads/2021/03/image-57.png)
Then you can find the source code that has been downloaded in folder “C:\bcartifacts.cache\sandbox\”.
![](https://yzhums.com/wp-content/uploads/2021/03/image-59.png)
Then all the app files will also be downloaded to the “C:\bcartifacts.cache\sandbox\17.4.21491.22792\w1\Extensions” folder at the same time. Including “Microsoft__Exclude_Microsoft Dynamics 365 – SmartList_17.4.21491.21867.app”.
![](https://yzhums.com/wp-content/uploads/2021/03/image-58.png)
Then you can extract the app file and view the source code, as above.
![](https://yzhums.com/wp-content/uploads/2021/03/image-60-1024x545.png)
PS:
1. You can add some parameters to the Get-BCArtifactUrl command to download the source code you need.
For example:
View the latest version of JP region.
Get-BCArtifactUrl -country "jp"
![](https://yzhums.com/wp-content/uploads/2021/03/image-61.png)
View all version of Sandbox type.
Get-BCArtifactUrl -Type Sandbox -Select All
![](https://yzhums.com/wp-content/uploads/2021/03/image-62.png)
Download the source code for the specified version and region.
Download-Artifacts -artifactUrl (Get-BCArtifactUrl -country "jp" -version "15.4.41023.43672") -includePlatform
![](https://yzhums.com/wp-content/uploads/2021/03/image-63.png)
2. If you also want to add your own Query inside All of the pages, you can check out the blog below.
QueryCategory property – Smartlist? (Execute Queries from Pages)
END
Hope this will help.
Thanks for reading.
ZHU
コメント