Skip to content

Foundry Lab 02 - Hello Name Integration Service

Duration 15 Min

What you will learn

You'll learn how to create an integration 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

  • Lab 01 completed

Steps

helloName.vss

  1. For completeness, in atlas.json, add a second element to mainScripts called "helloName.vss".
  2. Create a file "helloName.vss" in the src directory.
  3. Type "foundry" and accept the Foundry Boilerplate snippet.
  4. 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
  5. Save the file.

Package for Volt Foundry

  1. From the Command Palette, run "VoltScript: Package for Foundry".
  2. Enter the project directory, confirm atlas.json locations and continue with nothing entered for additional files to package.

Success

A file is created in the root of the project called "foundry-lab.1.0.0.zip". The zip name comprises the project name and the project version from the atlas.json.

Update Volt Foundry Integration Service

  1. Log into Volt Foundry.
  2. On the Apps page, select the app you created in Foundry Lab 01.
  3. On Configure Services tab, click the Integration tab.
  4. Click the Service Definition tab for the "foundry-lab-vs" integration service.
  5. Click Upload New and select the zip file you just created. You will receive a warning that this will update the endpoint operations. Click OK.
  6. Set the Name to "helloName".
  7. Click SAVE & ADD OPERATION.
  8. Select "helloName.vss" as the file.
  9. Click ADD OPERATION.

    ADD OPERATION

  10. Scroll down to the bottom of the operation and click SAVE AND FETCH RESPONSE.

    SAVE & FETCH RESPONSE

    Success

    The Output Result shows the following JSON object:

    {
        "ErrorCode": "7060",
        "ErrorMessage": "Error occurred while processing the VoltScript. Cause Please enter username."
    }
    
  11. On the Request Input tab of the operation, click + Add Parameter.

  12. Set the NAME to "username".
  13. Set the TEST VALUE to "John Doe".
  14. Scroll down to the bottom of the operation and click SAVE AND FETCH RESPONSE.

    ENTER PARAMETER

    Success

    The output result shows the following JSON object:

    {
        "opstatus": 0,
        "message": "Hello John Doe",
        "httpStatusCode": 0
    }