Calling a Service

How to call a BAW service to retrieve or update information
Written by Nick Laughton
Updated 1 year ago

Retrieve a list of Covid-19 testing sites for a given postal code

Our example is a service to return a list of potential testing sites for specified postal code. We can link this function into our form to retrieve the data on the scheduling form. The steps to create an action to update non-process data would be very similar.

Example Service

Our example service is called Retrieve Testing Sites.  It has "zipCode" as an input and testingSites (a list of testing site) as an output variable. Our test service passes back a list of possible sites based on the zipCode. In our case the sites have been hard coded but the service could just as easily query a database to get the list.

Other than writing the service, the only action you have to perform in BAW is to allow Ajax Access to all users on the overview tab

Create the Function

Once you are Apex Forms and have selected your process application, you can go to the functions tab to create the new function to call the service. Once you are on the tab, you can discover the available services by clicking on the magnifying glass at the end of the Add a function... line.

Do that will bring up a dialog of all of the availabe servies that can be discovered. You can select a single one by clicking on it or press the discover all button to create a function for each one.

Discover the Service Inputs and Outputs

The discovery process creates a function of type action that can be linked to an action on a form, section or field of your form. The generated function would look like this:

Now if we go to our form, we can edit the form by clicking on the pencil icon and going to the actions tab of the dialog that has opened.

Clicking the action will open the actions dialog where you can add another action. In our case we already have one action named Start Current Task and we will add our Retrieve Testing Sites action by selecting the action from the drop down.

Now we have to map our input and outputs. In our case the input will be our testAreaZipCode variable and our output will be sent to the testingSites variable.

We can close the dialogs and now when we run our forms we will see that our data is retrieved into our form for us.

Did this answer your question?