I really dislike when ServiceNow doesn't share the functions they make
available and use in their code in front of us. See this thread on the
community
. Anyways,
there are efforts to keep track of these things. I know I've contributed
to this page on
serviceportal.io.
s You can get the list of all the methods available by running this in
Xplore;

var sp = new GlideSPScriptable();
sp;
Method Documented
addQueryString No
buildThemeVariableModel No
canReadRecord Yes
equals No
getCatalogItem Yes
getClass No
getDisplayValue Yes
getField Yes
getFields Yes
getFieldsObject Yes
getFilterBreadcrumbs No
getForm Yes
getGuide No
getHTTPS No
getInstanceRecord No
getItemDisplayPrice No
getKBCategoryArticles Yes
getKBCategoryArticleSummaries Yes
getKBCount Yes
getKBRecord No
getKBSiblingCategories No
getKBTopCategoryID No
getKBTopicArticles No
getListColumns Yes
getMenuHREF Yes
getMenuItems Yes
getParameter Yes
getPortalGR No
getPortalRecord Yes
getRecord Yes
getRecordDisplayValues Yes
getRecordElements Yes
getRecordValues Yes
getRecordVariables No
getRecordVariablesArray No
getRectangleRecord No
getRelatedList No
getSCRecord No
getStream Yes
getStreamEntries No
getSubCategories No
getUserInitials Yes
getValue Yes
getValues Yes
getVariablesArray No
getWidget Yes
getWidgetFromInstance No
getWidgetFromRectangle No
getWidgetParameters No
getWidgetScope No
hashCode No
isServicePortalURL No
log No
logSearch No
logStat No
mapUrlToSPUrl No
notify No
notifyAll No
saveRecord No
saveVariables No
showCatalogPrices No
stripHTML No
translateTemplate No
wait No

canReadRecord #

Method Notes
canReadRecord(GlideRecord)
canReadRecord(string table, string sys_id)
// Returns true if the user can read the specified GlideRecord.
// source: SQANDA Create Question[sqanda-create-question] line 40:
if (!$sp.canReadRecord(questionGR)){

}
// source: SC Popular Items[cbcacf13cb21020000f8d856634c9ca0] line 14:
$sp.canReadRecord(
"sc_cat_item",
count.cat_item.sys_id.getDisplayValue()
);

getCatalogItem #

Method Notes
getCatalogItem(string sys_id)
getCatalogItem(string sys_id, boolean)
// Returns a model and view model for a sc_cat_item or
// sc_cat_item_guide.
// source: SC Catalog Item[widget-sc-cat-item] line 50
data.sc_cat_item = $sp.getCatalogItem(data.sys_id, true);
// source: sp-variable-editor[sp-variable-editor] line 25
data.sc_cat_item = $sp.getCatalogItem(
gr.cat_item,
!!options.isOrdering,
targetTable
);

getKBCategoryArticleSummaries #

getKBCategoryArticleSummaries(sys_id, number,
maxChars)

Returns Knowledge Base article summaries in the specified category and
its subcategories.

// KB Categories - KBv3[ee307070d7201200a9addd173e24d4da]
/* Line 17: */ if (kbCount < 500) { // if more than 500 articles, don't iterate to get viewable counts
/* Line 18: */ var arts = $sp.getKBCategoryArticleSummaries(cats.getUniqueValue(), 0, 0);
/* Line 19: */ articleCount = arts.length;

// KB Category Page[fb5d068cd7610200a9ad1e173e24d400]
/* Line 13: */ data.categoryDisplay = kb_cat.getDisplayValue();
/* Line 14: */ data.items = $sp.getKBCategoryArticleSummaries(data.category, 0, 250);
/* Line 15: */}

getDisplayValue #

getDisplayValue(stringfield)

// Returns a display value from a field on a record in this order:
// 1. The widget's sp_instance* record
// 2.
// source: SC Catalog Item[widget-sc-cat-item] line 4
data.sc_catalog_page = $sp.getDisplayValue("sc_catalog_page");

getField #

getField(GlideRecord, string
field)

// Returns {display_value, label, type, value} for a given field
// on a GlideRecord.
// source: Approval Info[33442352cb30020000f8d856634c9c3f] line 21
fields.push($sp.getField(
gr,
'sys_updated_on'
));

getFields #

getFields(GlideRecord, string
fields)

// Like getField Checks the specified field names, and returns
// a comma seperated list of valid names.
// source: Approval Info[33442352cb30020000f8d856634c9c3f] line 18
var fields = $sp.getFields(
gr,
'state,sys_created_on'
);

getFieldsObject #

getFieldsObject(GlideRecord, string
fields)

// Checks the specified field names, and returns an object
// containing the valid names.
// source: Approval Record[525a2752cb30020000f8d856634c9cfd] line 15
var t = {};
t = $sp.getFieldsObject(
task,
'number,short_description,opened_by,requested_by,start_date'
);

getForm #

Method Notes
getForm(string table, string sys_id)
getForm(string table, string sys_id, string query, string view)
// Returns the form.
// If no view is passed, returns the form as it appears on view 'sp'
// source: User Profile[user-profile] line 22
$sp.getForm("live_profile", data.liveProfileID);
// source: Form[widget-form] line 63
data.f = $sp.getForm(data.table, data.sys_id, data.query, data.view);

getListColumns #

getListColumns(string table, string
view)

// Returns a list of the specified table's columns in the specified
// view
// source: Data Table[widget-data-table] line 37
data.fields = $sp.getListColumns(data.table, data.view);

getMenuHREF #

getMenuHREF(GlideRecord)

// Returns the (?id=) portion of the URL based on the sp_menu type.
// source: Icon Link[3caa67afcb13020000f8d856634c9c2e] line 3
data.href = $sp.getMenuHREF(gr);

getMenuItems #

getMenuItems(string
sys_id)

// Returns the menu items for the specified instance.
// source Header Menu[5ef595c1cb12020000f8d856634c9c6e] line 8
data.menu.items = $sp.getMenuItems(menu_id);

getParameter #

getParameter(string)

// Returns the value of a given key from the query string or post body.
// source: Form[widget-form] line 37
data.query = $sp.getParameter("query") || options.query;

getPortalRecord #

getPortalRecord()

// Returns the portal's GlideRecord.
// source: Subscribed Questions[sqanda-subscribed-questions] line 2
data.knowledgeBase = $sp.getPortalRecord().getValue("sqanda_knowledge_base");

getRecord #

Method Notes
getRecord()
getRecord(string table, string sys_id) Not Documented, only works in global scope.
// Returns the GlideRecord for the current sp_instance\*.
// Returns null if the widget is embedded by another widget.
// source: Request Fields[96cf39f3d7230200a9addd173e24d412] line 2
var gr = $sp.getRecord();
// source: Form[widget-form] line 54
var rec = $sp.getRecord(data.table, data.sys_id);

Note: Feedback submitted on 04/24/2018 page:
https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_GSPS-getRecord

What are you trying to do now? Look up information
Were you successful? no
Tell us more
$sp.getRecord is missing information.
getRecord(string table, string sys_id) as depicted in OOB widget `widget-form` line54
var rec = $sp.getRecord(data.table, data.sys_id);

This however doesnt work in scoped apps.

getRecordDisplayValues #

getRecordDisplayValues(object data, GlideRecord, string
fields)

// Copies display values for the specified field names
// from a GlideRecord into the data parameter.
// source: Catalog Content[sc-cat-content] line 26
$sp.getRecordDisplayValues(c, gr, 'picture');

getRecordElements #

getRecordElements(object data, GlideRecord, string
fields)

// Copies the value and display value for the specified
// field names from a GlideRecord into the data parameter.
// source: Data Table[widget-data-table] line 128
$sp.getRecordElements(record, gr, data.fields);

getRecordValues #

getRecordValues(object data, GlideRecord, string
fields)

// Copies values for the specified field names from a
// GlideRecord into the data parameter.
// source: KB View 2[c254be50d7201200a9addd173e24d410] line 6
$sp.getRecordValues(data, gr, 'title,description');

getStream #

getStream(string table, string
sys_id)

// Get the activity stream for a record.
// source: Ticket Conversations[widget-ticket-conversation] line 63
data.stream = $sp.getStream(data.table, data.sys_id);

Note: This only returns the quantity of entries specified by the
property, glide.service_portal.stream_entry_limit. Default is 100.

getUserInitials #

getUserInitials()

// Returns the user's initials as a string.

getValue #

getValue(string
field)

// Like getDisplayValue except that it returns the value instead of
// the display value.
// source: SC Popular Items[cbcacf13cb21020000f8d856634c9ca0] line 1
data.sc_catalog = $sp.getValue('sc_catalogs') || $sp.getValue('sc_catalog');

getValues #

Method notes
getValues(object data, string fields)
getValues(string sys_id, object options)
getValues(object data) Not Documented
//source: KB Topic Articles[35c51f56d7f33100a9ad1e173e24d4b1] line 2
$sp.getValues(data, "color,glyph,kb_topic,title");
//source: Icon Menu List[88979930cb01020000f8d856634c9caa] line 2
$sp.getValues(data);

getWidget #

getWidget(string sys_id/widget-id, object
options)

// Returns a widget model for embedding a widget inside another widget.
// source: User Profile[user-profile] line 75
data.teamWidget = $sp.getWidget(
'sp-my-team',
{glyph: 'user', color: 'primary'}
);

mapUrlToSPUrl #

mapUrlToSPUrl()

/* Line 98:  */    if (redirectURL && redirectURL != "true") {
/* Line 99: */ var spUrl = new GlideSPScriptable().mapUrlToSPUrl(redirectURL);
/* Line 100: */ returnUrl = spUrl ? this.portal + "?" + spUrl : redirectURL;

isServicePortalURL #

isServicePortalURL()

/* Line 65: */      var nt = session.getProperty("nav_to");
/* Line 66: */ var isServicePortalURL = new GlideSPScriptable().isServicePortalURL(nt);
/* Line 67: */ var redirectURL = session.getProperty("login_redirect");
/* Line 68: */
/* Line 69: */ if (user.hasRoles() && !redirectURL && !isServicePortalURL)
/* Line 70: */ return;

translateTemplate #

translateTemplate()

/* Line 27: */          if (searchGroupTemplatesGR.advanced_typeahead_config)
/* Line 28: */ data.typeaheadTemplates["sp-typeahead-" + searchGroupTemplatesGR.getValue("id") + ".html"] = $sp.translateTemplate(searchGroupTemplatesGR.getValue("typeahead_template"));
/* Line 29: */ }

stripHTML #

stripHTML()

/* Line 21: */      if (!!instance.description)
/* Line 22: */ instance.description = $sp.stripHTML(instance.description);
/* Line 23: */ });

getRelatedList #

getRelatedList()

/* Line 1:*/ data.slides = $sp.getRelatedList('sp_carousel_slide','carousel');

getGuide #

getGuide()

/*Line 152:*/   data.showPrices = $sp.showCatalogPrices();
/*Line 153:*/ data.sc_cat_item = $sp.getGuide(data.sys_id, true, false);
/*Line 154:*/ if (data.sc_cat_item.category) {

getKBRecord #

getKBRecord()

// Returns the portal's KB record where the workflow state is
// published.
// source: KB Most Viewed[7d903b52cb30020000f8d856634c9ce3] line 4
var z = $sp.getKBRecord();

getKBCount #

getKBCount(string
sys_id)

// Returns the number of Knowledge Base articles.
// source: KB Categories - KBv3[ee307070d7201200a9addd173e24d4da] line 16
var kbCount = $sp.getKBCount(data.kb);

getKBCategoryArticles #

getKBCategoryArticles(string
sys_id)

// Returns KB articles in the specified category and its
// subcategories.Pass 'limit' to limit the number of
// articles returned.
// source: KB Categories[122ac7f0d7101200a9addd173e24d411] line 9
var articles = $sp.getKBCategoryArticles(t.getUniqueValue());

getKBTopicArticles #

getKBTopicArticles(string
topic)

// Returns array
// source: KB Topic Articles[35c51f56d7f33100a9ad1e173e24d4b1] line 3
data.items = $sp.getKBTopicArticles(data.kb_topic);

getKBTopCategoryID #

getKBTopCategoryID(string
sys_id)

// Returns the top category in the hierarchy containing the
// specified category.
// source: KB View 2[c254be50d7201200a9addd173e24d410] line 22
n.topCat = $sp.getKBTopCategoryID(n.kb_category);

getKBSiblingCategories #

getKBSiblingCategories(string
sys_id)

// Returns KB categories with same parent as the specified
// category.
// source: KB Categories - KBv3[ee307070d7201200a9addd173e24d4da] line 6
cats = $sp.getKBSiblingCategories(data.catParam);

showCatalogPrices #

showCatalogPrices()

// Returns- Is an object|
// source: SC Catalog Item[widget-sc-cat-item] line 20
data.showPrices = $sp.showCatalogPrices();

saveVariables #

saveVariables()

// Retuns ?
// source: sp-variable-editor[sp-variable-editor] line 17
$sp.saveVariables(
input.table,
input.sys_id,
vars
);

buildThemeVariableModel #

buildThemeVariableModel(string sys_id,
array)

// Retuns ?
// source: Portal config[widget-portal-config] line 241
var variableValues = $sp.buildThemeVariableModel(portalId, keys.join(","));

getVariablesArray #

getVariablesArray()

// Returns the tables variables as an object.
// source: Request Fields[96cf39f3d7230200a9addd173e24d412] line 22
data.variables = $sp.getVariablesArray();

getWidgetFromInstance #

getWidgetFromInstance(string)

// Returns a widget from the specified widget instance.
// source: KB Search[9b6187d0d7201200a9addd173e24d4dd] line 1
data.typeahead = $sp.getWidgetFromInstance('typeahead_search_header');

getRecordVariablesArray #

getRecordVariablesArray(GlideRecord)

// Returns the records variables.
// source: Approvals[f37aa302cb70020000f8d856634c9cfc] line 86
item.variables = $sp.getRecordVariablesArray(itemsGR);

getFilterBreadcrumbs #

getFilterBreadcrumbs(string table, string, query,
null)

// Returns an array of objects where each object contains
// the breadcrumb label, value, and flags for if fixed and
// if removed
// source: Filter Breadcrumbs[widget-filter-breadcrumbs] line 4
data.breadcrumbs = $sp.getFilterBreadcrumbs(table, query, null);

logStat #

Method Notes
logStat(string param 1, string table, string sys_id, string param 2)
logStat(string param 1, string table, string sys_id)
// Create a new entry in the `sp_log` table.
// Record has a table name, a record sys_id from that name,
// and some type and optional comments.
// Handy for doing things like logging searches or visits
// to pages, etc.
// source: SC Catalog Item[widget-sc-cat-item] line 59
$sp.logStat(
'Catalog View',
data.sc_cat_item.sys_class_name,
data.sys_id,
data.sc_cat_item.name
);
// source: SC Order Guide[widget-sc-order-guide] line 38
$sp.logStat(
'Catalog Order Guide View',
data.sc_cat_item.sys_class_name,
data.sys_id
);

getInstanceRecord #

getInstanceRecord()

// Returns the widget instances GlideRecord.
// source: Icon Link[3caa67afcb13020000f8d856634c9c2e] line 2
var gr = $sp.getInstanceRecord();

log #

Method Notes
log(string)
log(object)
// Sends the specified message to the log console.
// source: Calculator[calc] line 7
$sp.log("calc with input as follows... ");
// source: Preview Widget[core-preview] line 21
$sp.log(e);

saveRecord #

saveRecord(string table, string sys_id, array fields)

// Saves or updates the current record.
// source: Form[widget-form] line 25
result = $sp.saveRecord(
input.table,
input.sys_id,
input._fields
);

logSearch #

logSearch()

// Adds a record to the Service Portal Statistics logs.
// no examples in a new instance

getSCRecord #

getSCRecord()

// Returns sc_cat_item record for the portal's catalog with
// sys_class_name != sc_cat_item_wizard and active = true
// in the query. GlideRecord returned has not yet triggered
// the query.
// no examples in a new instance

getStreamEntries #

getStreamEntries()

// Get a record's actvivity stream as a JSON formatted list.
// Typically for a task record