VoltScript in Foundry Lab 02 - Hello Name Integration Service
Duration 15 Min
What you will learn
You'll learn how to create an Integration Service with an input parameter, validate the input parameter and error or return a JSON object including a message element that says "Hello" to the username sent.
Prerequisites
- VoltScript in Foundry - Lab 01 completed.
Steps
We're going to build off of our work in VoltScript in Foundry - Lab 01 to create a second VSS library using the Foundry VoltScript editor.
Create helloName.vss
Since we've already added the VSS and VSE libraries we need when completing Lab 01 we can begin by creating our new library.
- Log into your Volt Foundry server.
- Open the App you created in Lab 01.
- Click on the Integration tab.
- Click on your Integration Service.
-
In the VoltScript Editor area, click on the VSS Files tab, click Add (+), then select Add New File.
-
In the Add New File dialog, enter "helloName.vss", then click Add.
-
in the editor, click on the new
helloName.vss
file. You should see the VoltScript boilerplate code. -
Between the two comment blocks, enter the following code:
If (VoltMxRequest.getInputParam("username") = "") Then Call VoltMxResult.setErrorMessage("Please enter username") Else Call VoltMxResult.result.insertValue("message", "Hello " & VoltMxRequest.getInputParam("username")) End If
-
Click the SAVE ZIP button.
-
Click on SAVE & ADD OPERATION at the bottom of the screen. When you click SAVE & ADD OPERATION, it takes you to the Operations List tab where you can add an Operation to test your code.
Add An Integration Service Operation
- Set the name to "helloName".
- Select "helloName.vss" as the file.
-
Click ADD OPERATION.
-
Scroll down to the bottom of the operation and click SAVE AND FETCH RESPONSE button.
-
On the Request Input tab of the operation, click + Add Parameter.
- Set the NAME to "username".
- Set the TEST VALUE to "John Doe".
-
Scroll down to the bottom of the operation and click SAVE AND FETCH RESPONSE.
The code for the lab is available on GitHub.