NSO Service Model Form Fields
  • 05 Dec 2024
  • Dark
    Light
  • PDF

NSO Service Model Form Fields

  • Dark
    Light
  • PDF

Article summary

Guidelines

  • To view device elements from a service model in Form Builder, you will need to specify where to find the YANG files. In newer versions of NSO adapter (version 4 and higher), this is configured in the yangdirs property of the adapter.
  • To view service models in older versions of NSO adapter (pre version 4), include your YANG schemas in the load-path of ncs.conf.
  • For more information on configuring the NSO adapter to get YANG, check the NSO NETCONF documentation for the adapter.

Create a Form Using NSO YANG Service Model

The following steps correspond to the labels shown in the figure below. To build a form on an NSO YANG service model:

  1. Select the appropriate service from the Data Elements dropdown list.
    • The leafs defined in the model will automatically display below the dropdown box.
  2. Drag-and-drop the fields to assign them to the form.
    • By default, the field label is the same as the leaf from the service model. See id in the example figure below.
    • To update the field label, click the field and type a new label.
  3. Assign the Lists defined in NSO to the form.
  4. Group the fields together within a Container.
    • Click the Add Container button to assign a Container to a Form.
    • Toggle the direction icon (double arrow in left corner) to arrange the Containers horizontally or vertically. Containers can also be nested within other Containers.
  5. Assign a name to the Form.
  6. Click Save.

Figure 1: Form from NSO Yang
03-formFromNSOYang

Meta Data Fields

In addition to creating a form using the leafs defined in an NSO Yang service model, you can assign Meta Data Fields to a form. Three field types and a checkbox are available.

  • Text Box - Allows any characters.
  • Number Field - Accepts only numerical values.
  • Checkbox - A Boolean field that can be checked or unchecked.
  • Dropdown - Accepts one selected option from a dropdown list.

Figure 2: Meta Data Fields
04-metaDataFields

Preview a Form

Once a form is saved, click the Form Preview button (eye icon) in the title bar to preview the form.

Figure 3: Preview Form
05-previewForm1

All form fields are editable in Preview mode, even those configured as a lead reference or enumeration in the YANG service model, just as they are when the form is allocated to a Workflow. The figure below illustrates the dropdown list generated by an NSO leaf reference.

Figure 4: Preview Form Dropdrown
06-previewFormDropdown

Enable or Disable Constraints

The Validate Constraints checkbox in Forms allows a user to bypass the must statement validations defined in the YANG service models. The checkbox works at the form level, which means that disabling the checkbox will disable validations for the entire form. The checkbox does not, however, disable other form validations.

Examples

The example below shows a form with a leaf description which has constraints defined for length of the string (it must be between 3 to 8 characters). The leaf is a must statement (leafWithMust) that says the length of the leaf description should be exactly 5.

Figure 5: Form with Must
07-formWithMust

As seen below, the leaf description has only two characters, hence an error message is displayed for the leaf.

Figure 6: Form with Validation Error
08-formWithValidationError

Disabling the Validate Constraints checkbox did not remove the error message for the field as expected.

Figure 7: Form with Error Constraint Disabled
09-formWithErrorConstraintDisabled

In the form below, it can be seen that validation of the description field passed since the number of characters is now three, but we can see that the field leafWithMust has failed since it requires the description field to have 5 characters.

Figure 8: Form with Must Error
10-formWithMustError

However, when the Validate Constraints checkbox is not checked (disabled), validation of the must statement is disabled and now the form reports no errors.

Figure 9: Form without Errors
11-formWithNoErrors

Mandatory vs. Required Field Constraint Validation Criteria

When building forms in Form Builder, some fields are mandatory, which means they must display a value in the field, and it cannot be overridden. Mandatory fields will always show a red asterik (*) or the text "Required" next to the field label. Constraints can also be set to restrict the values that display in the field, oftentimes based on the value of another field. This is known as field constraint validation, which helps to ensure valid form data is submitted. If the expected data is missing or incorrectly formatted, an error message is displayed with user feedback that explains what is needed.

Below are a few use case examples to show field constraint validation in forms.

Examples

As seen below, the Mandatory constraint validation is working as expected.

Figure 10: Mandatory Fields
18-mandatoryField

For Required field constraint validation, there is a dependency between the key and the required field element that triggers the constraint validation. When a nested table key is not entered (set as required), the form will skip the table row.

Figure 11: Required Fields
19-requiredField

For this use case, the table key is missing in the submitted form, and the output renders a garbage form. In this scenario, the form will submit, but the table row will be ignored, no matter if the user filled out Field A or Field B or both.

Figure 12: Missing Table Key
20-missingTableKey

Below is the output data from this form. It does not contain any fields from the table row since it’s been ignored.

Output (Garbage)

{
  "name": [
    "test"
  ]
}

For this validation scenario, the table key was entered on the form, but the user cannot submit without filling out the required fields.

Figure 13: Missing Required Field
21-missingRequiredField

A successful scenario will show a valid table key along with the required field inputs.

Figure 14: Valid Key Required Field
22-validKeyReqField

Below is the expected output from a successful validation.

Output (Expected)

{
  "name": [
    "testValCrit"
  ],
  "table": [
    [
      {
        "key": "1",
        "fieldA": "A",
        "fieldB": "B"
      }
    ]
  ]
}

Resources

For more information on field constraint validation, see:

Edit Form Field Properties

Once a field has been allocated to a form, you can configure some of its properties.

  1. Hover your mouse over the field.
  2. Click the Configure Properties icon (top-right corner). The Configure dialog box opens.

Figure 15: Configuration Button
12-configurationButton

Figure 16: Configure Propeties
13-configureProperties

Property Description
Custom Label Adds a custom label above the field.
Field Key An internal value that identifies the field from the underlying workflow engine code. Update this value only for a Meta Data Field. Do not modify this value when the field is part of an NSO YANG service model.
Info/ Tool Tip Adds a custom tool tip that displays when your cursor is placed over the field.
Required When checked, a Form cannot be submitted unless a value has been entered in the Number field that displays.
Read-Only When checked, the field is visible to users but they will not be able to modify the value.
Hide Field When checked, the field is hidden from users. The field will still be available to the underlying Workflow Engine code.
Min Length The minimum number of characters a Text field must contain before it can be submitted. Requires the user to define a numeric value.
Max Length The maximum number of characters a Text field may contain before it can be submitted. Requires the user to define a numeric value.
Regex Patterns Does not apply to any fields that have been assigned an NSO leaf reference or enumeration.
Custom Error Message Adds a custom error message that displays when user input is invalid. Requires that Field Type be defined.

Delete a Form Field

To remove a form field, click the trashcan icon.

Figure 17: Remove Form Field
14-removeFormField


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.