Configure Web Services through Code in Business Central - CloudFronts

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:

  1. Business Central
  2. VS Code with AL Language Extension

Demonstration:

  1. Create a Setup Page having a boolean variable say ‘SetupExtension‘ and create a field having value as ‘SetupExtension Variable’.

    Output:
  2. 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.
  3. 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.


Share Story :

SEARCH BLOGS :

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange