Visual map — Ch.03 · Service Catalog — intake
Category → Record Producer → variables → publish
Submit Leave Request → req_v2
Development
Full visual path (all chapters): VISUAL_FROM_SCRATCH_00_16.html
Studio-only from scratch: Service Catalog intake for leave requests. Requires req_v2 table and employee role from chapters 01–02.
Also open: Properties + Direct Links · Schema · Studio Create All Objects · Previous: 02 Administration
How catalog objects relate
Part 1 Category (HR Leave)
│
▼
Part 2 Record Producer → Part 3 Variables
│
▼
Part 4 Producer script (maps variables → req_v2)
│
▼
Part 5 Publish → Employee Center / Portal catalog
│
▼
BR1 days + approver → BR2 event → Flow approval
Flow: employee1 opens catalog → submits → req_v2 inserted in submitted state → same lifecycle as UI Action Submit.
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: Catalog Category — HR Leave
Purpose
Groups the Submit Leave Request record producer under a dedicated HR Leave catalog category.
Navigation path
Direct URL
Prerequisites
- Part 1: Application Setup (01 Development).
- Rule 0 Update Set current.
Form fields
| Field | Value |
|---|---|
| Title | HR Leave |
| Description | Leave requests and balances |
| Active | true |
| Order | 100 |
| Application | HR Leave |
Step-by-step create
- Service Catalog → Categories → New.
- Fill Title, Description, Order from table. Active = true.
- Submit. Note category sys_id for record producer.
Verify checklist
- Category HR Leave appears in category list.
Demo / test
Open Employee Center → catalog browse → HR Leave category visible (after producer published).
Part 2: Record Producer — Submit Leave Request
Purpose
Service Catalog item that inserts submitted req_v2 from catalog variables.
Navigation path
Direct URL
Prerequisites
- Part 3: Table — Leave Request (01).
- Part 1: Roles employee role (02).
- Part 1: Catalog Category.
Form fields
| Field | Value |
|---|---|
| Name | Submit Leave Request |
| Table | x_786686_hr_leave_req_v2 |
| Category | HR Leave |
| Roles | x_786686_hr_leave.employee |
| Active | true |
| Application | HR Leave |
Step-by-step create
- Record Producers → New. Fill header fields from table.
- Category = HR Leave. Table = req_v2. Roles = employee.
- Save. Continue to Part 3 for variables and Part 4 for script.
Verify checklist
- Producer record saved under HR Leave application.
Demo / test
Open producer form → Table field shows x_786686_hr_leave_req_v2.
Part 3: Catalog Variables
Purpose
Four question variables mapped by the producer script to req_v2 u_* fields.
Navigation path
Direct URL
Prerequisites
- Part 2: Record Producer created.
Form fields — each variable New
| Name | Label | Type | Question | Mandatory |
|---|---|---|---|---|
| leave_type | Leave Type | Choice | Leave Type | Yes |
| start_date | Start Date | Date | Start Date | Yes |
| end_date | End Date | Date | End Date | Yes |
| reason | Reason | Multi Line Text | Reason | No |
Choice values for leave_type: annual, sick, personal (match req_v2 u_leave_type choices).
Step-by-step create
- Open Submit Leave Request producer → Variables related list → New.
- For each row: Name must match producer.* references in script. Set Label, Type, Mandatory.
- Order: leave_type, start_date, end_date, reason.
Verify checklist
- Four variables on producer; names exactly leave_type, start_date, end_date, reason.
Demo / test
Try It → variable form renders all four questions.
Part 4: Producer Script
Purpose
Server-side script maps catalog variables to req_v2 fields and sets state submitted. Source: src/catalog/RP_submit_leave.js.
Navigation path
Direct URL
Prerequisites
- Part 3: Catalog Variables.
- Part 8: BR1 calculates days on insert.
Step-by-step create
- Open producer → Script tab.
- Paste full script below.
- Save.
Full script (paste-ready)
/**
* Record Producer Script: Submit Leave Request
* Application: Custom · Scope: x_786686_hr_leave · sys_id: 83d5298c932b8f107520703efaba1072
* Target table: x_786686_hr_leave_req_v2
*
* Maps producer variables to record fields. Runs server-side when submitted.
* Variables expected: leave_type, start_date, end_date, reason
*/
(function () {
current.u_requested_for_user = gs.getUserID();
current.u_leave_type = producer.leave_type;
current.u_start_date = producer.start_date;
current.u_end_date = producer.end_date;
current.u_reason = producer.reason;
current.u_state = 'submitted';
// Link to employee profile of the current user (if exists)
var emp = new GlideRecord('x_786686_hr_leave_employee_v2');
emp.addQuery('u_user', gs.getUserID());
emp.query();
if (emp.next()) {
current.u_employee_ref = emp.getUniqueValue();
}
// BR1 will calculate days and set the approver on insert.
})();
Verify checklist
- Script saves without syntax errors.
Demo / test
Background: no errors on save. Catalog submit tested in Part 5.
Part 5: Publish and Test
Purpose
Publish catalog item and verify end-to-end submit from Employee Center.
Navigation path
Direct URL
Prerequisites
- Parts 1–4 complete.
- employee1 user with employee role and employee_v2 seeded.
Step-by-step create
- Record Producer → Related Lists → Catalogs → add to HR Leave category.
- Service Catalog → open producer → Publish.
- Login as employee1 → Employee Center → HR Leave → Submit Leave Request.
- Fill variables → Submit.
- Verify req_v2 created in submitted state; u_days_count and u_approver_user set by BR1.
- Verify Flow starts for manager1 approval.
Verify checklist
- Catalog item visible to employee role.
- Submit creates req_v2 in submitted state.
- sysapproval_approver row for manager1.
Demo / test
employee1 submits → req_v2 row, BR1 sets days + approver, Flow starts.
Service Catalog verify checklist
Complete after Parts 1–5.
- HR Leave category active.
- Record Producer scoped to HR Leave with four variables.
- Producer script from src/catalog/RP_submit_leave.js pasted.
- Published and visible in Employee Center.
- E2E submit creates submitted req_v2.