HR Leave · Australia

Scripted REST Inbound — Complete Setup (Dev + Admin)

ServiceNow Australia · Custom app · Arabic + English readable · scripts copy/paste ready

App typeCustom
Scopex_786686_hr_leave
sys_idc84db0e8839f0b509f02b0d6feaad3c9
Replace{BASE} = your instance
Instance URLs Studio Business Rules Client Scripts Script Includes

Scripted REST Inbound — Complete Setup (Dev + Admin)

Fixes common errors:
- The following mandatory fields are not filled in: Default ACLs
- Application = Global (wrong) → must be HR Leave scope
- API namespace shows 2065034 instead of x_786686_hr_leave

الأسلوب: عربية + إنجليزية تكمّلان بعضهما — بدون ترجمة حرفية لأسماء الشاشات.
Test after setup: REST API Explorer ($restapi.do) — see rest_api_explorer.md


Phase 0 — Switch to scoped application (DO THIS FIRST)

If Application shows Global on the form, you are in the wrong context. — إذا كان Application = Global فأنت خارج تطبيق الإجازات — هذا سبب namespace خاطئ.

Steps

  1. Top-right Application picker (or Studio).
  2. Select: HR Leave (scope x_786686_hr_leave).
  3. Verify:
    Navigate: All > System Applications > Applications — Open direct
    Open HR Leave → Scope = x_786686_hr_leave

  4. Optional — create from Studio (recommended):
    - URL: /now/studio
    - Open app HR Leave
    - Create Application File → Scripted REST API — بعد التبديل، عند إنشاء Scripted REST يجب أن ترى Application = HR Leave وليس Global.


Phase 1 — Admin: Role + Integration user (before API form)

1.1 Create integration role

Navigate:
All > User Administration > Roles → New — Open direct

Field Value to enter
Name x_786686_hr_leave.integration
Display name HR Leave Integration
Application HR Leave (scoped)
Elevated privilege false
Assignable by (default)

Submit. — هذا الدور يُستخدم في Default ACLs ليسمح لنظام HR الخارجي بالاستدعاء.

1.2 Create integration user

Navigate:
All > User Administration > Users → New — Open direct

Field Value to enter
User ID hrlx.integration
First name HRLX
Last name Integration
Email [email protected] (any valid format)
Active true
Password set strong password (lab)
Web service access only false (lab: leave false so you can impersonate)
Internal integration user false (lab) / true (prod optional)

Roles (Related list → Edit):

Role Why
rest_service Required to call REST APIs
x_786686_hr_leave.integration Allowed by Default ACLs
x_786686_hr_leave.employee Insert leave via table ACL (create) — lab
OR x_786686_hr_leave.hr_admin Lab shortcut only — not for production

Submit.

1.3 System property (optional but professional)

Navigate:
All > System Properties → New (scope HR Leave) — Open direct

Name Type Value
x_786686_hr_leave.config.integration_user string hrlx.integration

Phase 2 — Admin: Default ACLs (fixes your red error)

Default ACLs is mandatory on Scripted REST Service. You must attach at least one ACL before Submit. — حقل Default ACLs إلزامي — بدون ACL لن يقبل Submit (كما في صورتك).

  1. Open Scripted REST New form (after Phase 0 — app = HR Leave).
  2. Fill Name and API ID first (see Phase 3 table).
  3. Go to tab Security.
  4. Find Default ACLs (red asterisk).
  5. Click the lock icon (or +) next to Default ACLs → New ACL record opens.

Fill the new ACL:

ACL field Value
Active true
Operation execute
Type scripted_rest_api (or Scripted REST API in UI)
Scripted REST API (may auto-link after parent saves — if empty, save API first then edit ACL)
Requires role x_786686_hr_leave.integration
Admin overrides false (prod) / true (lab only)
Advanced false

For lab testing add second ACL or add role admin on same ACL so your admin user can test in Explorer.

  1. Save ACL → return to Scripted REST form.
  2. Default ACLs list collector → add the ACL you created.
  3. Now Submit works.

Method B — Create ACL manually first, then attach

Navigate:
All > System Security > Access Control (ACL) → New — Open direct

Field Value
Type scripted_rest_api
Operation execute
Name HRLX Leave API execute (label)
Active true
Requires role x_786686_hr_leave.integration
Application HR Leave

Submit.

Then on Scripted REST New → Security → Default ACLs → magnifier → select this ACL.

Method C — Path-based ACL (public API pattern)

Use when you need per-method control (GET vs POST).

Navigate:
All > System Security > Access Control (ACL) → New — Open direct

Field Value
Type rest_endpoint (if available on your instance)
REST API path /api/x_786686_hr_leave/hrlx_api_v2/*
HTTP method POST (or * for all)
Operation execute
Requires role x_786686_hr_leave.integration

Attach to Default ACLs the same way.


Phase 3 — Dev: Scripted REST Service (every field)

Navigate (scoped app HR Leave selected):
All > System Web Services > Scripted REST APIs → New — Open direct

Tab: General / top section

Field Required Value Notes
Name Yes HRLX Leave API Display name
API ID Yes hrlx_api_v2 Lowercase, no spaces; used in URL
Protection policy No – None – Lab default
Application Yes HR Leave NOT Global
API namespace Read-only x_786686_hr_leave Must match scope prefix
Description No Inbound API to create leave requests from HRIS Optional
Active — true If field exists

Wrong vs right (your screenshot issue):

Field Wrong Correct
Application Global HR Leave
API namespace 2065034 x_786686_hr_leave

Tab: Security

Field Value Notes
Default ACLs Select ACL from Phase 2 Mandatory — fixes submit error
Requires authentication true No anonymous calls
Requires ACL authorization true Enforces Default ACLs

Blue info boxes on form:
- Default ACLs apply to all resources unless resource has its own ACLs.
- For public APIs use path-based ACLs — we use role-based for HRIS.

Submit the Scripted REST Service record.


Phase 4 — Dev: Resource (endpoint) — every field

Open saved API → Related list Resources → New

Field Required Value
Name Yes Create Leave
HTTP method Yes POST
Relative path Yes /leave
Relative path format — Must start with /
Active — true
Requires authentication — inherit from API (true)
Requires ACL authorization — inherit (true)
Default ACLs No empty = use API Default ACLs
Request processor — default
Script Yes paste inbound_scripted_rest_leave.js

Resource script prerequisites

Before testing, confirm these exist in scope HR Leave:

Artifact Navigate
Script Include HRLXProIntegrationUtilsV2 sys_script_include.list
Table x_786686_hr_leave_employee_v2 employee with u_employee_id = EMP001
Table x_786686_hr_leave_req_v2 target table
ACL create on req table src/security/acls.md ACL 3 + integration role

Submit Resource.

Final URL:
https://.service-now.com/api/x_786686_hr_leave/hrlx_api_v2/leave


Phase 5 — Admin: Table ACL for integration insert

REST ACL allows calling the API. Table ACL allows inserting the leave row. — ACL الـ REST ≠ ACL الجدول — تحتاج الاثنين.

Update ACL 3 (create on leave request)

File: src/security/acls.md

On ACL create for x_786686_hr_leave_req_v2, script should allow integration role:

answer = gs.hasRole('x_786686_hr_leave.employee')
 || gs.hasRole('x_786686_hr_leave.hr_admin')
 || gs.hasRole('x_786686_hr_leave.integration');

Or add Requires role (multi):
x_786686_hr_leave.employee,x_786686_hr_leave.integration

Test with Impersonate:
All > User Administration > Impersonate User → hrlx.integration → try create record on form. — Open direct


Phase 6 — Test in REST API Explorer

Navigate:
All > System Web Services > REST API Explorer — Open direct
URL: $restapi.do

Explorer field Value
Namespace x_786686_hr_leave
API name hrlx_api_v2
Resource leave
Method POST

Request body:

{
 "employee_id": "EMP001",
 "leave_type": "annual",
 "start_date": "2026-06-01",
 "end_date": "2026-06-05",
 "reason": "Vacation"
}

Click Send.

Response Meaning Fix
201 + sys_id Success —
401 Not authenticated Login / Basic Auth
403 ACL denied Phase 2 Default ACLs + Phase 5 table ACL
404 Wrong URL Application scope + API ID
422 Business validation Create employee EMP001
500 Script error Check Script Include + logs

Verify record:
x_786686_hr_leave_req_v2.list

Impersonate test:
1. Impersonate hrlx.integration
2. Repeat Send in Explorer (or Postman with Basic Auth)


Phase 7 — Sample data for professional practice

7.1 Employee (required for employee_id lookup)

Table: x_786686_hr_leave_employee_v2

Field Sample value
u_user link to test employee sys_user
u_employee_id EMP001
u_department IT
u_manager manager sys_user

7.2 Leave types / state (choices)

Field Allowed values
u_leave_type annual, sick, unpaid
u_state API usually creates then BR sets; script may set submitted

Checklist — copy before go-live


File Purpose
inbound_scripted_rest_leave.js Resource script
rest_api_explorer.md Explorer quick reference
12_INTEGRATION_FULL_GUIDE.md Full integration map
02_ADMINISTRATION.md § Integration Admin summary
src/security/acls.md Table ACLs