This article is a continuation of a previous article in which an example Http endpoint was configured.
In the following example, we will show how the previously configured Http endpoint can be used in a WorkPoint process.
As a reminder, the Http endpoint configured in the previous example returns data of Danish companies provided a company name.
In the following example, we will configure the "Entity Form" step of a process to accept input from the configured Http endpoint. We will be able to search for a company using it's name, and use the search result to fill in the Title and CVR number fields in the Entity Form.
for the purpose of this example, we have set up the following WorkPoint process:
- To edit the Entity Form step, we simply click it. This opens the settings panel for the step:
- Since we want to edit settings for a field in the Entity Form, we open the "Fields" tab.
- Next, we select and expand the field which we want to fill out using the Http endpoint we have configured. In this case, we want the VAT number to be filled with the CVR number from the company we search for.
- In the options for the VAT number field, under "Data source" we click the "Data source" button.
This opens the "Data binding" panel on which we can configure the data source for the VAT number field:
- First, we provide the Data binding with a title. In this example, we provide the same name as the Http endpoint title.
- For "Type" we select "Endpoint" and in "Endpoint" we select the Http endpoint we configured earlier. In this example, it was called "SearchCVRWithCompanyName".
- The "Parameters" section of the panel will display the parameters we added in the Http endpoint configuration. In this example, there is a single parameter, called "Name". Here we can either hard code a value which will always be used for the parameter, or we can use an expression to make it possible to use a search query for the name parameter. Since we want to be able to provide a company name to search for, we click the "Expression" button.
This opens the Parameter - Name panel:
- In the "Type" field, we select "Search Query" option.
- We then click the "Close" button to close the Parameter - Name panel and return to the previous panel. The "Expression" button should now be highlighted to show that the field has been configured:
Next, we need to configure which of the returned properties to fill the selected field with.
- Next to the "Value Property" field we click the property selector button.
- In the property selector, we select which property returned by the API to fill the Title field with. In this example, we expand the "virksomhedsnavn" (company name) group and select the "vaerdi" (value) property.
The selected property should now appear in the "Value Property" field:
Next, we will add the "CVR" number to both the "Title property" and the "Description Property" fields:
For this example, we will also enable "Typeahead":
- To enable Typeahead, simple enable the checker. Typeahead makes it possible for the system to start searching when the user has input a small set of characters instead of having to wait for a full query and the push of a search button.
At this point, we can save and publish the process and start using it to create companies using data from our endpoint.
Before we do this however, we will configure the system to automatically fill in the VAT number in our form with CVR data from our endpoint when we select a result in the Title field.
First, we close the Data binding panel for the title field:
- In the Data binding panel for the Title field, click the "Close" button.
- Next, we expand the options for the "VAT Number" field.
- for the "Value" field, we click the "Advanced" button.
- In this instance, we want to use an expression to tell the system to take information from the data binding of the Title field and fill the VAT number with some data from the endpoint response for the title. In the configuration panel for the VAT number field, under "View" we click "Advanced".
- The system lets us know that if we change to the Advanced view, the current settings for the Value field of the VAT Number field will be reset. To proceed we click "OK".
- In the "Expression" section, we type in the expression which lets the system know to fill the VAT Number field with data from the Title data binding. The "getValue" method helps us get a value from another field. We need to provide the getValue method with a field which has a data binding set up to get a response from a Http endpoint. In this case, the Title field from the EntityForm is set up to be filled in using a response from a Http endpoint, and the response also includes the CVR number of the company we look up. We therefore provide "EntityForm.Title" as the first parameter of the getValue method. Note that for the first parameter, you must use the internal field name of the field. For the second parameter of the getValue method, we need to provide the property name of the Http endpoint response which value we want to fill the VAT number field with. In this case, we want the VAT Number field to be filled with the CVR number which is provided by the Http endpoint response. That property in the response is called "CVRNummer", so we type that in as the second parameter. The full expression is then the following:
- We can now close the configuration panel for the VAT number field.
We can now also save and publish the process:
- We click "Save as draft".
- We can then click the "Publish" or "Republish" button to publish our changes.
3. End User Guide
Visit this article for a guide on how to use WorkPoint processes which uses Http endpoints.