17 Dec’18

D365 Business CentralConfigure 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.

Written by

Olister Rumao

Software Engineer

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • 3 Biggest all-time ERP Myths

    17 January’ 2019

    Introduction: In my personal experience over the years, whenever I dealt with business owners, directors, and CTOs in t...

    Read more
  • Create a Customer, Vendor, or Bank Account from a Contact

    16 January’ 2019

    Introduction: Companies want to record some of contacts as customers, vendors, or bank accounts. Creating a customer, v...

    Read more
  • Creating an Email activity in MS CRM through WebApi

    16 January’ 2019

    Introduction: This blog explains how to Create an Email activity in MS CRM through WebApi Request: Post URL:  <yo...

    Read more
  • Time entry using model driven PowerApps

    10 January’ 2019

    Introduction: Managers and employees need a good time entry application to record worked hours for billing, payroll, or...

    Read more
  • Formatting Address Data separated by delimiter in the single field

    10 January’ 2019

    Introduction: Whenever the a single field in NAV contains Name, Address and other values seperated by delimiter such as...

    Read more