Contents

Widget instance options

SAVE AS PDF

Other

Widget instance options

Widget developers can configure their own options for a widget instance.

Widget instances allow users to uniquely configure each widget they add to a page. When you
build a widget from scratch you can also add instance options to your widget using the Option
Schema.

An Option Schema is a way of defining what properties users of your widgets can define. Any
properties declared here display when a user is editing the instance of a widget. Use the
Option Schema to enable users to declare many types of fields, from primitive String and
Numbers to reference fields.

From the Service Portal Configuration page, navigate to the Widget Editor, and select
the widget you want to configure the Option Schema for.

Click the menu icon () and select Edit Option Schema.

Click the + icon to add a widget option with a label, a name, a type, and a hint.

Save your changes, then view your configuration by navigating to an instance of the
widget on a page. Then Control + right-click the widget and select Instance
Options.

Use options in a widget

Access options in the widget from both the client script and the server script.

(function() {
$sp.log(options.text_color) //Logs the value of the text_color option to the browser console.
})();

Default options

Before an option value is set on an instance, it appears as an undefined value when you
access that option variable. Use the server script of a widget to specify default values for
your options, in order to handle the situation where those option values haven't been
provided yet.

This site is scheduled for a small content update on Monday, November 19th, between the hours of 3:30pm and 5:00pm Pacific Time (Nov 19 23:30 – Nov 20 1:00 UTC). Acces to this site may be slightly delayed during that time.

Exit Preview Mode

A new experience, personalized for you.

Browse content relevant to you when you pre-set your search preferences.