Store instance options in a table

Create a table to store widget instance options instead of editing the existing option schema. When using a table as your widget option schema, you can define custom fields using any ServiceNow field type, add filters to fields, and search or query instance options.

Before you begin

Role required: admin or sp_admin

About this task

To define a custom option schema, add fields to an sp_instance extension table, then set your widget to use the extension table as a data source. Using an extension table enables you to:

  • Add any ServiceNow field type, including fields with advanced customization, to the option schema.
  • Define complex widget options.
  • Search and filter instance options.
Note: While storing options in a table enables you to define more complex options, this method is more difficult to maintain than editing the option schema. To avoid creating unnecessary tables and adding additional server calls to your widget, edit the existing option schema when possible. Store options in a table only when complex or searchable options are required.

Procedure

  1. Create a table that extends an sp_instance table to store your custom option schema.
    1. Navigate to System Definition > Tables.
    2. Click New.
    3. Define a label and name.
    4. In the Extends table field, select an sp_instance table that provides the necessary fields.
      Instance table Description
      Instance [sp_instance] Includes base instance fields.
      Instance with Table [sp_instance_table] Includes sp_instance fields and fields to display table data such as Table and Filter.
    5. Save the form.
  2. Define custom fields in the extension table.
    You can define any field type to use in your option schema by adding new columns in the Columns list.
  3. Update your widget to use the extension table as a data source.
    1. Navigate to Service Portal > Widgets.
    2. Open the widget you would like to create custom options for.
    3. In the Data table field, select your sp_instance extension table.
  4. Configure the extension table form to display the desired fields. Fields configured on the form are available as instance options.
    1. Navigate to the extension table form: <yourInstance>/<your_extenstion_table>.do.
    2. Right-click the header menu and select Configure > Form Layout.
    3. Add the fields to the form.
    4. Click Save.
  5. Configure the widget to display the desired fields as instance options.
    1. Navigate to Service Portal > Widgets.
    2. Open the widget that has the extension table set as the data source.
    3. Use the Fields slushbucket to select fields to display as instance options.
    4. Save the form.

What to do next

Test the option schema by adding the widget to a page in the Service Portal Designer. Click the edit icon on the widget instance to view the instance options. After configuring the widget instance options, view the configuration by navigating to the instance record in the sp_instance extension table.