spUtil

Set of methods that perform common, often re-used functions.

Method Description
addErrorMessage(String message) Displays a notification error message
spUtil.addErrorMessage("There has been an error processing your request")


Method Description
addInfoMessage(String message) Displays a notification info message
spUtil.addInfoMessage("Your order has been placed")


Method Description
addTrivialMessage(String message) Displays a notification trivial message
spUtil.addTrivialMessage("Thanks for your order")


Method Description
get(String widgetId) Gets a widget model by id or sys_id. Returns Promise.
spUtil.get("widget-cool-clock").then(function(response) {
    c.coolClock = response;
});


Method Description
format(String, Object) Alternative to string concatenation

Let's say you want to build a string with variables: 'An error occurred: ' + error + ' when loading ' + widget instead of doing string concatenation you can use format().

spUtil.format('An error ocurred: {error} when loading {widget}', {error: '404', widget: 'sp-widget'})


Method Description
refresh(Object $scope) Calls the server and automatically replaces the current options and data from the server response. Returns Promise

Same as server.refresh() The diference is that you can define what $scope to pass over.


Method Description
recordWatch(Object $scope, String table, String filter, Function callback) watch for a table / filter update - callback when it happens
spUtil.recordWatch($scope, "live_profile", "sys_id=" + liveProfileId);

More documentation on recordWatch can be found here.


Method Description
update(Object $scope) Calls the server and this.data is automatically send to server side. Returns Promise.

Same as server.update(). The diference is that you can define what $scope to pass over.

Do not try to use any other methods from spUtil() that are not listed here

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match