Widget Development
Develop Service Portal widgets with ScriptSync and troubleshoot template.html script tags becoming escaped or corrupted during sync.
Last updated: November 17, 2026
sn-scriptsync has special features for Service Portal widget development.
Opening a Widget
Open a widget in the widget editor (try /spw creator):
Click the save button to sync to VS Code:
Widget File Structure
In VS Code, widgets are organized differently:
- Folder - Created with the widget name inside
sp_widgetfolder - Multiple files - Each field becomes a file (e.g.,
template.html,client_script.js,server_script.js,css.scss) - _test_urls.txt - Sample URLs where the widget is rendered (you can add your own)
Live Development
CTRL-Click (CMD-Click on Mac) a URL in _test_urls.txt to open the widget in a browser:
Script Changes
Edit client_script.js and save. For example, change:
this.showFilter = true;
The page refreshes automatically and shows your changes.
Live CSS Updates
Open css.scss with both VS Code and browser visible. As you type CSS changes, they apply instantly without saving:
This makes CSS development much faster - see changes in real-time as you type!
Script Tags Escaped When Saving Widget HTML
If saving template.html through ScriptSync changes <script to <script, removes script-tag attributes, or breaks a template that saves correctly in ServiceNow's widget editor, ServiceNow REST input sanitization is a likely cause. ScriptSync sends saves through the Table REST API; the widget editor uses a different save path. This can affect template tags such as type="text/ng-template" and type="text/x-handlebars-template", not just executable JavaScript. Similar escaping can affect UI Macros.
Ask your instance administrator to review glide.rest.sanitize_request_input. Setting it to false resolved the matching behavior in a confirmed ScriptSync report, but disables a REST input protection. This is an instance security decision, not a routine ScriptSync setting: have the administrator assess it under your organization's policy before any change.
If saving the same content in the widget editor already works, use that as a temporary workaround and keep the original HTML. Avoid pushing an older or escaped local copy back over it. If the setting does not explain the difference, include a minimal non-sensitive example and the helper tab's save result in your support report.
Summary
sn-scriptsync transforms widget development:
- Edit in VS Code with full IDE features
- Automatic sync on save for scripts
- Real-time CSS preview without saving
- Test URLs for quick access to rendered widgets