ServiceNow ServicePortal Cheat Sheet for Quick development
|
Evaluate the given expression when the user changes the input.
|
ng-change="expression" |
|
Sets the checked attribute on the element
|
ng-checked="boolean" |
|
This directive sets the disabled attribute on the element
|
ng-disabled="boolean" |
|
The ngHide directive shows or hides the given HTML element based on the expression provided to the ngHide attribute.
|
ng-hide|show="boolean" |
|
The ngMousedown directive allows you to specify custom behavior on mousedown event.
|
ng-mousedown="expression" |
|
Specify custom behavior on mouseover event
|
ng-mouseover="expression" |
|
Specify custom behavior on blur event. A blur event fires when an element has lost focus.
|
ng-blur="expression" |
|
Run a loop with the data in array
|
ng-repeat="([key,] value) in object|array" |
|
Evaluate an if condition
|
ng-if="expression" |
this.server.get([Object]) |
Calls the server and sends custom input. Returns Promise.
|
this.server.update() |
Calls the server and posts this.data to the server script. Returns Promise.
|
this.server.refresh() |
Calls the server and automatically replaces the current options and data from the server response. Returns Promise.
|
|
Announce a message to a screen reader.
|
spAriaUtil.sendLiveMessage('Say Hello to screen reader'); |
function(spAriaUtil) {/ widget controller /var c =this;}
|
Displays a notification error message.
|
spUtil.addErrorMessage("There has been an error processing your request") |
|
Displays a notification info message.
|
spUtil.addInfoMessage("Your order has been placed") |
|
Displays a trivial notification message.
Trivial messages disappear after a short period of time. |
spUtil.addTrivialMessage("Thanks for your order") |
|
Use this method to embed a widget model in a widget client script. The callback function returns the full widget model.
|
spUtil.get('pps-list-modal', {title: c.data.editAllocations,table: 'resource_allocation',queryString: 'GROUPBYuser^resource_plan=' + c.data.sysId,view: 'resource_portal_allocations' }).then(function(response) {var formModal = response;c.allocationListModal = response;}); |
|
Formats a string as an alternative to string concatenation.
Use this method to build a string with variables. |
spUtil.format('An error ocurred: {error} when loading {widget}', {error: '404', widget: 'sp-widget'}) |
|
Calls the server and replaces the current options and data with the server response.
|
spUtil.refresh($scope) |
|
Updates the data object on the server within a given scope.
|
spUtil.update($scope) |
|
Watches for updates to a table or filter and returns the value from the callback function.
|
spUtil.recordWatch($scope, "problem", "active=true", function(response) {// Returns the data inserted or updated on the tableconsole.log(response.data);}); |
function(spUtil,$scope) {/ widget controller /var c =this;}
<div><p>${This message will be translated.}</p><p>However, this will nessage will NOT be translated.</p></div>
if the user can read the specified GlideRecord. |
$sp.canReadRecord(<gliderecord>) |
if the user can read the specified record with table and sysID |
$sp.canReadRecord('table', 'sys_id') |
if the currently logged in user has permission to view the specified page |
GlideSPScriptable.canSeePage("page_id") |
Returns a model and view model for a sc_cat_item or sc_cat_item_guide. |
$sp.getCatalogItem(sys_id) |
Returns the display value of the specified field (if it exists and has a value) from either the widget's sp_instance or the sp_portal record. |
$sp.getDisplayValue("sc_catalog") |
Returns the portal record from the Service Portals [sp_portal] table. |
$sp.getPortalRecord() |
Returns an array of Service Catalog variables associated with a record. |
$sp.getRecordVariablesArray('sc_req_itemGlide record',true(if you want variables with no values)); |
Gets a widget by id or sys_id, executes that widget's server script using the provided options, then returns the widget model. |
$sp.getWidget('widget_id', {p1: param1, p2: param2}); |
Interact with data and perform record operations in Service Portal widgets.You access GlideSPScriptable methods by using the global $sp object.
{{fa-asterisk}} Creating a reference Field
<sn-record-picker field=""
table="'sys_user'"
display-field="'name'"
display-fields="'user_name'"
value-field="'sys_id'"
search-fields="'name'"
default-query="'nameLIKEAdmin'"
page-size="100" ></sn-record-picker>
{{fa-asterisk}} The sp-date-picker allows to select a date and time in widgets
<sp-date-picker field="fromdate"
ng-model="c.from"
ng-model-options="{getterSetter: true}"
sn-include-time="true"
sn-disabled="false"></sp-date-picker>
|
True if user has not interacted with the form yet.
|
$pristine |
|
True if user has already interacted with the form.
|
$dirty |
|
Displays an alert.
|
spModal.alert('Thanks for the update').then(function (answer) {c.simple = answer;}); |
|
Displays a confirmation message.
|
spModal.confirm("Can you confirm or deny this?").then(function(confirmed) {c.confirmed = confirmed; // true or false}) |
|
Opens a modal window using the specified options.
|
spModal.open({title: 'Give me a name',message: 'What would you like to name it?',input: true,value: c.name}).then(function(name) {c.name = name;}) |
|
Displays a prompt for user input.
|
spModal.prompt("Your name please", c.name).then(function(name) {c.name = name;}) |
function(spModal) {/ widget controller /var c =this;}
<div> <widget id="widget-cool-clock"></widget></div><widget id="widget-cool-clock" options='{"zone": "America/Los_Angeles","title": "San Diego, CA"}'></widget>|
Initializes a key and adds widget data as the value.
|
spContextManager.addContext('agent-chat', { 'approval_count': 5 }); |
|
Returns each key and associated data object defined by any widget on the page.
|
spContextManager.getContext(); |
|
Returns the widget data associated with a key.
|
spContextManager.getContextForKey('agent-chat', true).then(function(context) { context = context || {}; context.approval_count = 5; spContextManager.updateContextForKey('agent-chat', context); }); |
|
Sends data to an existing key.
|
spContextManager.getContextForKey('agent-chat', true).then(function(context) { context = context || {}; context.approval_count = 5; spContextManager.updateContextForKey('agent-chat', context); }); |
function ($scope, spContextManager) {var c =this;}
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.