Loading Organization Details from an External Service

Tags: v8preview5 v8

Starting from V8Preview5, it is possible to simplify the filling of fields when editing organization data. The user only needs to enter the VAT number, and then the plugin will search in the external system, and SyrveFront will fill in the other details of the company.

To achieve this, a new method RegisterExternalCompanyInfoSearchProvider has been added to the API, which allows registering a method in SyrveFront that performs the function of a provider for searching organizations by VAT number. It is assumed that in the callback method getCompanyInfoCallback, the plugin developers will call an external service to search for a company by VAT number. Thus, a waiter, while in the “Organization Details” window, will be able to automatically obtain information about a new organization or update the data of an existing one.

To transfer information about the organization from the plugin to SyrveFront, a class ExternalCompanyInfo has been added. In the arguments of RegisterExternalCompanyInfoSearchProvider, a callback method Func<string, ExternalCompanyInfo> getCompanyInfoCallback is passed, which takes a string with the VAT number of the sought organization as input and returns information about the organization in the dto type ExternalCompanyInfo.

The data about the organization returned by the getCompanyInfoCallback method will be displayed in the “Organization Details” window. For an already existing organization in SyrveFront, the getCompanyInfoCallback method will be called in the “Organization Details” window by clicking the “Update” button, taking the value from the “VAT number” field as input. For a new organization being added to SyrveFront, the getCompanyInfoCallback method will be called after clicking the “External Search” button in the “Organization Details” window when the “Search for and add a new organization” dialog box is opened and the “Search” button is pressed. In this case, the argument for the callback method will be the value entered in the search field.