Visual map — Ch.15 · Scripts library
Paste from scripts/ portal into Studio
One source of truth
Development
Full visual path (all chapters): VISUAL_FROM_SCRATCH_00_16.html
Studio-only from scratch: Use AI assistants or local editors to draft code, then paste into matching ServiceNow Studio forms while Application = HR Leave.
Also open: Properties + Direct Links · Schema · Studio Create All Objects · Previous: 14 AI Agents
How script files map to chapters
Part 1 paste workflow → Part 2 mapping table (file → chapter Part). Full scripts live in linked Parts — not duplicated here.
Rule 0 — Before any object (Application + Update Set + Studio)
Repeat these checks before creating or editing any application file. This section is also section 00 Update Set — create the capture set first.
- Application picker — top-right globe / application menu → select HR Leave (
x_786686_hr_leave). Never leave Global selected when creating scoped artifacts. - Update Set — All → System Update Sets → Local Update Sets → New:
After submit: open the record → click Make Current. Direct list: {BASE}/sys_update_set_list.doField Value Name HR Leave – BuildApplication HR Leave State In Progress Description Captures all HR Leave lab artifacts - Open Studio — {BASE}/$studio.do → confirm header shows HR Leave.
If artifacts land in Global scope, delete them and recreate under HR Leave. ACLs and events created globally will not behave correctly for this app.
Verify Update Set: Create a test Script Include in Studio → open HR Leave – Build → Related List Customer Updates shows the new file.
Part 1: Paste Into Studio Instructions
Purpose
Standard workflow for copying scripts from disk or Scripts portal into Studio forms.
Navigation path
Step-by-step create
- Application picker = HR Leave (
x_786686_hr_leave). - Update Set HR Leave – Build = current.
- Open the chapter Part for the object (form fields + navigation path).
- Open matching file under
HR_Leave_App/src/OR Scripts portal. - Copy entire script — include header comment block.
- Paste into Studio Script field (Business Rule, Script Include, Record Producer, Widget server, etc.).
- Save → run that Part Verify + Demo checklist.
Do not paste into Global-scoped records. Confirm Application = HR Leave on the form before save.
Verify checklist
- No syntax errors on save.
- Customer Updates captures the script change.
Demo / test
One script at a time: paste → save → verify behavior before next file.
Part 2: Script File → Chapter Part Mapping
Purpose
Quick index: which source file maps to which chapter Part (links — not full script bodies).
| Source file (src/) | Object | Chapter · Part (Full script) |
|---|---|---|
server/script_includes/HRLXProLeaveUtilsV2.js | Script Include | 01 Part 6 |
server/script_includes/HRLXProSecurityUtilsV2.js | Script Include | 01 Part 7 |
server/business_rules/BR1_calculate_days.js | Business Rule | 01 Part 8 |
server/business_rules/BR2_on_submit_event.js | Business Rule | 01 Part 9 |
server/business_rules/BR3_audit_state_change.js | Business Rule | 01 Part 10 |
server/business_rules/BR4_on_approve_reject_event.js | Business Rule | 01 Part 11 |
client/client_scripts/CS1_validate_dates.js | Client Script | 01 Part 12 |
client/client_scripts/CS2_calc_days_glideajax.js | Client Script | 01 Part 13 |
catalog/RP_submit_leave.js | Record Producer | 03 Part 4 |
server/scheduled_jobs/annual_accrual.js | Scheduled Job | 06 Part 3 |
portal/widgets/hrlx_my_leaves/*.js | Widget client/server | 04 Part 1 |
portal/widgets/hrlx_balance/*.js | Widget client/server | 04 Part 2 |
server/script_includes/HRLXProIntegrationUtilsV2.js | Script Include | 12 Part 1 |
server/rest/inbound_scripted_rest_leave.js | REST resource | 12 Part 3 |
Browse all: Scripts portal · Inventory: SCRIPTS_INVENTORY.html
Verify checklist
- Every row opens a Part with Full script block.
Demo / test
Pick one row → paste → run linked Part demo.
Scripts chapter verify checklist
- Paste workflow followed.
- Mapping table covers BR, SI, catalog, job, portal, REST.