HR Leave · Australia

15 — Scripts: Copy Into Studio Only

Paste-ready script mapping — link to chapter Parts, do not duplicate huge scripts here

Scopex_786686_hr_leave
sys_ide5f5bc9493a303507520703efaba104d
Instance labdev398980
URL token{BASE}
Quick open Visual map Scripts portal Studio

Visual map — Ch.15 · Scripts library

See in 10 seconds

Paste from scripts/ portal into Studio

You build

One source of truth

Track

Development

SRCscripts/
→
COPYBlock
→
PASTEStudio
→
SAVETest
✓ Diff after paste✗ Rename class ≠ record name

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.

  1. Application picker — top-right globe / application menu → select HR Leave (x_786686_hr_leave). Never leave Global selected when creating scoped artifacts.
  2. Update Set — All → System Update Sets → Local Update Sets → New:
    FieldValue
    NameHR Leave – Build
    ApplicationHR Leave
    StateIn Progress
    DescriptionCaptures all HR Leave lab artifacts
    After submit: open the record → click Make Current. Direct list: {BASE}/sys_update_set_list.do
  3. 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

  1. Application picker = HR Leave (x_786686_hr_leave).
  2. Update Set HR Leave – Build = current.
  3. Open the chapter Part for the object (form fields + navigation path).
  4. Open matching file under HR_Leave_App/src/ OR Scripts portal.
  5. Copy entire script — include header comment block.
  6. Paste into Studio Script field (Business Rule, Script Include, Record Producer, Widget server, etc.).
  7. 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

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/)ObjectChapter · Part (Full script)
server/script_includes/HRLXProLeaveUtilsV2.jsScript Include01 Part 6
server/script_includes/HRLXProSecurityUtilsV2.jsScript Include01 Part 7
server/business_rules/BR1_calculate_days.jsBusiness Rule01 Part 8
server/business_rules/BR2_on_submit_event.jsBusiness Rule01 Part 9
server/business_rules/BR3_audit_state_change.jsBusiness Rule01 Part 10
server/business_rules/BR4_on_approve_reject_event.jsBusiness Rule01 Part 11
client/client_scripts/CS1_validate_dates.jsClient Script01 Part 12
client/client_scripts/CS2_calc_days_glideajax.jsClient Script01 Part 13
catalog/RP_submit_leave.jsRecord Producer03 Part 4
server/scheduled_jobs/annual_accrual.jsScheduled Job06 Part 3
portal/widgets/hrlx_my_leaves/*.jsWidget client/server04 Part 1
portal/widgets/hrlx_balance/*.jsWidget client/server04 Part 2
server/script_includes/HRLXProIntegrationUtilsV2.jsScript Include12 Part 1
server/rest/inbound_scripted_rest_leave.jsREST resource12 Part 3

Browse all: Scripts portal · Inventory: SCRIPTS_INVENTORY.html

Verify checklist

Demo / test

Pick one row → paste → run linked Part demo.

Scripts chapter verify checklist

  1. Paste workflow followed.
  2. Mapping table covers BR, SI, catalog, job, portal, REST.