Configure Web Services through Code in Business Central
Introduction:
When coding an app that uses Webservices to connect to the integration solutions, it is generally recommended that there is a Setup, which we can configure, where the Webservices are created as well as deleted.
Pre-requisites:
- Business Central
- VS Code with AL Language Extension
Demonstration:
- Create a Setup Page having a boolean variable say ‘SetupExtension‘ and create a field having value as ‘SetupExtension Variable’.
Output: - On the OnOpenPage trigger add a code to Check if Web Services are already created and accordingly set the ‘SetupExtension‘ boolean field.
Thus, whenever the Setup Page is Opened, the ‘SetupExtension‘ field is set as per the records in Web Services. - On the OnQueryClosePage trigger write a code which will create the Web Services when ‘SetupExtension‘ boolean is set as ‘TRUE‘ and delete the Web Services if ‘SetupExtension‘ boolean is set as ‘FALSE‘.
Output:
i. When ‘SetupExtension‘ is set to ‘TRUE‘
New Webservices are created.
ii. When ‘SetupExtension‘ is set to ‘FALSE‘
Web Services are deleted.
Conclusion:
Thus this way we can keep the existing app installed and enable/disable Web Services as needed. As compared to creating WebServices.xml file which directly creates the Web Services on installation of the app, I’ll be demonstrating it in my next blog.
Related posts:
How to review and accept changes to confirmed Purchase Orders in D365 F&O
How to run an SSRS report on a selected record in the CRM using FetchXml
Project Operations as source of truth for Professional Services Organizations
Streamlining Build Pipelines with YAML Template Extension: A Practical Guide