Once we have created our Extension, we might need to auto Publish the web service when we install the Extension in Microsoft Dynamics Business Central.
If you want to Learn to create Extension in Microsoft Dynamics Business Central you can refer to Customer Requirement for AL Development.
To create web service while installing the extension, we have two method
- Create Install Codeunit.
- Create XML File.
Create Install Codeunit for MSDYN365BC
Below is the example of Install only Codeunit.
An install codeunit includes AL methods for performing operations unconcerned with the extension code itself during the initial installation and the reinstallation of an extension.
The Install codeunit started and the OnInstallAppPerCompany trigger does the work of publishing the web service.
When you install the Extension , below mentioned web service gets publised with Object Type PAGE , Object Id 50000 and Name InsuranceWS.
Create XML File.
We can use Snippet twebservices to create XML File.
You can define Object Type as mentioned below.
5 for Codeunit
8 for Page
9 for Query
Once you publish and install the extension you will find the new web service.
When you install the Extension , below mentioned web service gets publised with Object Type Codeunit , Object Id 50000 and Name InsuranceCUWebService.
Note: It’s recommended to use XML file because when you uninstall the extension, if the web service is published using the XML definition file it is automatically removed from the Tenant Web Service table while uninstalling the extension.while if the web service is published directly via AL code, it’s not removed from that table.
Hope this helps you for selecting an option for creating permission for you extension.
Download Link for different version of NAV and Business Central