HR Leave · Australia

Script — BR2_on_submit_event.js

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 Application Leave requests Business Rules Studio

Copy this script into ServiceNow under application x_786686_hr_leave (Australia). Table/API names already use the current scope.

Source: src/server/business_rules/BR2_on_submit_event.js

/**
 * Business Rule: BR2 - On Submit Fire Event
 * Application: Custom · Scope: x_786686_hr_leave · sys_id: c84db0e8839f0b509f02b0d6feaad3c9
 * Table:  x_786686_hr_leave_req_v2
 * When:   after
 * Update: true   Insert: true
 * Order:  200
 *
 * Fires an event when state becomes 'submitted' (drives notification / flow).
 */
(function executeRule(current, previous) {

    if (current.u_state.changesTo('submitted')) {
        gs.eventQueue(
            'x_786686_hr_leave.leave_v2.submitted',
            current,
            current.getValue('u_approver_user'),
            current.getValue('u_number')
        );
    }

})(current, previous);