Server & Debug
server.js running locally
The preview executes your Server Script in a Node sandbox, with faithful stubs of the ServiceNow API.
Server-side APIs
gs—getUser()(withgetDisplayName,getEmail,getLocation,hasRole, …),nowDateTime,info/warn/error,addInfoMessage/addErrorMessage, date helpers,getProperty, and 80+ methodsGlideRecord— when logged in, runs real queries via the Table API:addQuery,addEncodedQuery,orderBy,get(sysId),getValue,getDisplayValue, and dot-walking (gr.caller_id.name.toString())GlideAggregate—addAggregate('COUNT'|'SUM'|'AVG'|'MIN'|'MAX'),groupBy,orderBy(Desc)(live or from fixtures)- Script Includes —
new global.MyScriptInclude().method()is loaded on demand from the instance, evaluated and executed RESTMessageV2/sn_ws.RESTMessageV2— real outbound HTTP fromserver.js:setEndpoint,setHttpMethod,setRequestBody,execute()→RESTResponseV2. A relative endpoint resolves against the active instance with your session auto-injected; third-party hosts never receive your instance credentialsGlideDateTime— UTC-correct, ~30 methods:addSeconds/addDays/addWeeks/addMonthsUTC,subtract,before/after/equals/compareTo,getDayOfWeekUTC, …gs.getProperty(name)reads the realsys_propertiesvalue (cached per run), with default fallbackgs.getMessage(key, args)and${key}tokens resolve against your instance'ssys_ui_message(with{0}/{1}substitution)
gs.addInfoMessage(...) / spUtil.addInfoMessage(...) show up as banners at the top of the preview, just like the portal. There's a logs panel (gs.info/warn/error) in the preview's top bar.
Offline behavior
Without login (or with
offlineMode on), gs and GlideRecord use stub/fixture data; the widget still renders, but without real data. See Offline development.Client-side APIs in the preview
The preview also provides faithful Service Portal client APIs so client.js behaves like the portal:
spModal—alert / confirm / prompt / openrender a real modal and return a$qpromise. Embedded HTML renders,${token}labels are translated, and cancel rejects the promise — so.then(onOk, onCancel)works exactly as on the instancespUtil—get(widgetId, data)resolves a widget model ($q),recordWatchreturns an unsubscribe handle, plusaddInfoMessage/addErrorMessage,format, etc.g_form/g_user— available as ambient globals: in-memoryg_formseeded from your boot data, andg_userfrom your live (or preview) user
Embedded widgets
Embedded widgets (
<sp-widget> / <widget> / spUtil.get) currently render as a labeled placeholder — the nested widget tree is not yet executed offline. Use the real portal for those.High-fidelity artifacts (opt-in)
Complex widgets that rely on Angular sp_ng_templates, sp_angular_providers or shared dependency CSS can enable snWidgetKit.highFidelityArtifacts. When on (and logged in), the preview fetches those related records and injects them. Off by default, since it runs widget-provided Angular code and adds instance calls.