--- title: spModal - Client description: Shows alerts, prompts, and confirmation dialogs in Service Portal widgets. The spModal class is available in Service Portal client scripts.Displays an alert.Displays a confirmation message.Opens a modal window using the specified options.Displays a prompt for user input. locale: en-US canonical_url: https://www.servicenow.com/docs/r/australia/api-reference/SPModal-API.html release: australia product: API Reference classification: api-reference topic_type: concept last_updated: "2026-03-12" reading_time_minutes: 4 breadcrumb: [Client API reference, API reference, API implementation and reference] --- # spModal- Client Shows alerts, prompts, and confirmation dialogs in Service Portal widgets. The spModal class is available in Service Portal client scripts. The spModal class is a lightweight wrapper for Angular UI bootstrap's [$uibModal](https://angular-ui.github.io/bootstrap/#/modal). You can use the spModal.open\(\) method to display a widget in a modal dialog. **Parent Topic:**[Client API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/api-client.md) ## spModal - alert\(String message\).then\(fn\) Displays an alert. |Name|Type|Description| |----|----|-----------| |message|String|The message to display.| |Type|Description| |----|-----------| |Boolean|The promise contains a single argument that contains true or false.| ``` // HTML template // Client script function(spModal) { var c = this; c.onAlert = function () { spModal.alert('How do you feel today?').then(function (answer) { c.simple = answer; }); } } ``` ## spModal - confirm\(String message\).then\(fn\) Displays a confirmation message. |Name|Type|Description| |----|----|-----------| |message|String|The message to display.| |Type|Description| |----|-----------| |Boolean|The promise contains a single argument that contains true or false.| ``` // HTML template {{c.confirmed}} // Client script function(spModal) { var c = this; c.onConfirm = function() { c.confirmed = "asking"; spModal.confirm("Can you confirm or deny this?").then(function(confirmed) { c.confirmed = confirmed; // true or false }) } } ``` Confirm with HTML message: ``` //HTML template {{c.confirmed}} // Client script function(spModal) { var c = this; // more control, passing options c.onConfirmEx = function() { c.confirmed = "asking"; var warn = ''; spModal.open({ title: 'Delete this Thing?', message: warn + ' Are you sure you want to do that?' }).then(function(confirmed) { c.confirmed = confirmed; }) } } ``` ## spModal - open\(Object options\).then\(fn\) Opens a modal window using the specified options.
| Name | Type | Description |
|---|---|---|
| options | Object | An object that may have these properties. - backdrop: Boolean\|String. Controls the presence of a backdrop. Valid values: - true: Displays backdrop. - false: No backdrop. - static: Disables modal closing by selecting the backdrop. Default: true - buttons: Array. Buttons to show on the dialog. The default is Cancel and OK. - input: Boolean. When true, shows an input field on the dialog. Default: false - keyboard: Boolean. When true, indicates that the dialog is closeable using the ESC key. Default: true - message: String. HTML that goes in the header. Default: empty - noDismiss: Boolean. When true, indicates that the header section containing the close icon isn't present. Default: false - shared: Client-side object. Shares data with the embedded widget client script. - size: String. Size of the window. Valid values: 'sm' or 'lg'. Default: empty - title: String. HTML that goes in the header. Default: empty - value: String. Value of the input field. Default: empty - widget: String. Widget ID or sys\_id to embed in the dialog. Default: empty - widgetInput: Object. Sent to the embedded widget as input. Default: null |