spUtil API Reference

 spUtil enables you to perform common functions in a Service Portal widget client script.

How to Use: 

Pass in spUtil as a parameter in your Client Script function.

function (spUtil) {

spUtil.addInfoMessage(“Hello World“);

}

Method (Parameters) Description

addErrorMessage Displays a notification error message. (String message) Return: (Void)

addInfoMessage Displays a notification info message. (String message) Return: (Void)

addTrivialMessage Displays a trivial notification message. Trivial messages (String message) disappear after a short period of time.

Return: (Void)

clearMessages Clears any info or error message. Broadcasts

(N/A) “$$uiNotification.dismiss” event to rootscope.

createUid Uses a provided string to generate a UID.

(String str) Return: (String)

format Formats a string as an alternative to string concatenation.(String template, Use this method to build a string with variables. This method Object data) returns a formatted string.

Return: (String)

get Returns a widget model by ID or sys_id. Use this method to (String widgetId, embed a widget model in a widget client script. The callback Object data) function returns the full widget model. Checks the specified list of field names, and returns an array of valid field names. This method returns the model of the embedded widget.

Return: (Object)

getAccelerator If Mac user agent, returns back “Cmd + char”,

(String char) else “Ctrl + char”.

Return: (String)

getHeaders Returns an object containing header details, includes an (N/A) attribute which references the portal ID.

Return: (Object)

getHost Returns base instance URL (including https:// prefix).

(N/A) Return: (String)

getMomentTimeZone This will attempt to map a three letter timezone symbol into (N/A) it’s fully qualified name.

Return: (String)

getPageUri Returns page URI.

(N/A) Return: (String)

getPreference Looks up user preference value and then passes value (String preferenceName, into callback function.

Function callback) Return: (Void)

Method (Parameters) Description

getURL Utilized client side in conjunction with $http to submit catalog (String type, items.

Object type) Return: (String)

getWidgetURL Returns SNOW API REST endpoint URL used to

(N/A) communicate with SNOW instance.

Return: (String)

isMobile Scans current navigator user agent to determine if current (N/A) user is on a mobile device.

Return: (Boolean)

parseAttributes Given a string of URL attributes, returns an object containing (String attributes) same detail.

Return: (String)

recordWatch Watches for updates to a table or filter and returns the value (Object $scope, from the callback function. Allows a widget developer to

String table, String filter, respond to table updates in real-time. This method returns Function callback) the value of the callback function. When the record watcher triggers, it will call the callback function provided in this method (or simply trigger a $scope.server.update()).

Return: (Void)

refresh Calls the server and replaces the current options and data (Object $scope) with the server response. Calling spUtil.refresh() is similar to calling server.refresh(). However, when you call spUtil. refresh(), you can define the $scope object. This method returns the upated options and data objects.

Return: (Object)

scrollTo Scrolls view to the selector provided in the time provided.

(String elementID, The elementID refers to the actual ID of the element within Integer scrollDelayInMS) the widget. After a given delay, the selected element will scroll into view.

Return: (Void)

setBreadCrumb Given a list of breadcrumb labels/values, update (Scope $scope, breadcrumbs on the form.

Array list) Return: (Void)

setPreference Updates the user preference value.

(String preferenceName, Return: (Void)

String value)

setSearchPage Should emit an update.searchpage event with the search (String searchPage) page provided.

Return: (Void)

update Updates the data object on the server within a given scope. (String preferenceName, This method is similar to server.update(), but includes a

String value) $scope parameter that defines the scope to pass over.

This method returns the updated data object.

Return: (Object)


Comments

Popular Posts