HR Leave · Australia

SDK — business-rules.now.ts

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

Fluent/SDK example (Australia scope).

/**
 * HR Leave — Business Rules (Fluent example)
 * Application: Custom · Scope: x_786686_hr_leave · sys_id: c84db0e8839f0b509f02b0d6feaad3c9
 * Mirrors: src/server/business_rules/BR1_calculate_days.js
 */
import { BusinessRule } from '@servicenow/sdk/core';

export const BR1_calculate_days = BusinessRule({
    name: 'HRLX BR1 Calculate Days',
    table: 'x_786686_hr_leave_req_v2',
    when: 'before',
    insert: true,
    update: true,
    order: 100,
    active: true,
    script: `
(function executeRule(current, previous) {
    var util = new x_786686_hr_leave.HRLXProLeaveUtilsV2();
    if (current.u_start_date && current.u_end_date) {
        current.u_days_count = util.calculateBusinessDays(
            current.u_start_date,
            current.u_end_date
        );
    }
    if (current.u_employee_ref && !current.u_approver_user) {
        var emp = current.u_employee_ref.getRefRecord();
        if (emp.isValidRecord() && emp.u_manager)
            current.u_approver_user = emp.u_manager;
    }
})(current, previous);
`
});