- 18 Oct 2024
-
DarkLight
-
PDF
Create and Update Incident (ServiceNow) - JSON Forms
- Updated on 18 Oct 2024
-
DarkLight
-
PDF
Next, we’ll build our JSON Form. This form is how users will submit the information needed when running our Update Change Request automation.
JSON Form Video
Step 1
From the IAP Dashboard, click Automation Studio in the left navigation panel.
Step 2
From the Automation Studio homepage, click the + at the top of the left navigation panel.
Step 3
The Create window opens. Click the dropdown menu and select JSON Form in the What would you like to create field.
Step 4
Enter the name Lab - Incident - ServiceNow – XX (XX represents your initials) and click Create.
Step 5
JSON Forms utilize a drag and drop interface. By clicking Form Elements found on the right panel, you can select which types of fields appear in the form. There are seven types of form fields, or elements, to choose from. The first element we need is a Device Dropdown. Click and drag the Dropdown form element to the form canvas where we can see the text Drop elements here.
Step 6
When the element reaches the canvas, a red box will appear indicating where the element will be placed. Once the element has been added to the form, an ellipses icon will appear in the top-right corner. Hover your mouse over the ellipses and a gear icon will appear.
Step 7
Click the gear icon to configure the form element.
Step 8
The Configure window opens. The Dropdown element will be used for selecting a device. For Label, enter Device. Next, let’s make this a required field. Click the Yes radio button. For the Placeholder, enter Select a Device.
Step 9
Notice the warning telling us that options are needed. The Dropdown element requires options as part of its configuration. Select the + Options button in the lower right.
Step 10
There are 2 options for dropdown values, Static and Dynamic. Static options will not change once they are populated. Dynamic options can change and are populated via an API request. Dynamic dropdowns can be a valuable tool when it comes to offering your users dynamic data from your source of truth like NetBox, Infoblox, or GitLab. In this scenario, we are going to use it to pull a list of devices from Configuration Manager for the user to select. Click the Dynamic radio button.
Step 11
Here we will configure the API call used to populate our Dropdown field. First, select POST as the request method. Next, select the Base URL. For this exercise, we will be making a call to Configuration Manager within IAP, so select /configuration_manager. For the API Route, select /devices.
Copy the JSON data from below and paste it into the Request Body field.
{
"options": {
"start": 0,
"limit": 200,
"sort": [
{
"name": 1
}
],
"order": "ascending",
"filter": {
"name": "OS"
}
}
}
Step 12
Click Make API Call. This will send the API request you defined. Notice that the API response is now shown in the Response Body field.
Step 13
Now we will need to choose which data point we want to use for our values. First, we need to select which property contains our list of devices. Select /list as the Source Property and /name as the Property Key, then click the Query Data button.
Step 14
The dynamic dropdown values are shown. Click the Back button.
Step 15
Notice the options message has changed. Click Save. The dropdown has been configured.
Step 16
Add a second Dropdown element to the canvas and open the configuration window.
Step 17
For the Label, enter Command and select Yes for Required. For the Placeholder, enter Select a Command to Run. This dropdown field requires options. Click the +Options button.
Step 18
This dropdown will use Static values. Select Static and then click the +Option button three times to add three static values. Enter the following static values.
- show ip interface brief
- show running-config
- show arp
Step 19
Click Back and then click Save. The dropdown has been configured.
Step 20
Verify your JSON Form looks like the image shown and click Save.
Step 21
We would like to preview the format of the data leaving the JSON Form. Click the Preview icon.
Step 22
Complete the form by selecting IOS for the Device and any dropdown value for the command. Click Show Form Data.
Step 23
This is the format in which the data will be submitted when executing our automation in Operations Manager. Hover your cursor next to the text 2 items and select the clipboard icon. Paste the JSON text into a text editor, such as Notepad, for use in the next section of the training.
Click Close.
Step 24
We know that users will be submitting data using our form, but when doing so the values are not sent to the workflow individually as our workflow currently expects; they are sent in as a single variable called formData. To handle this, we will need to transform the data. To do that, we will build a Transformation.