HR Leave · Australia

SDK — script-includes.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 Studio Business Rules Client Scripts Script Includes

Fluent/SDK example (Australia scope).

/**
 * HR Leave — Script Includes (Fluent example)
 * Application: Custom · Scope: x_786686_hr_leave · sys_id: c84db0e8839f0b509f02b0d6feaad3c9
 * Mirrors: src/server/script_includes/HRLXProLeaveUtilsV2.js
 */
import { ScriptInclude } from '@servicenow/sdk/core';

export const HRLXProLeaveUtilsV2 = ScriptInclude({
    name: 'HRLXProLeaveUtilsV2',
    apiName: 'x_786686_hr_leave.HRLXProLeaveUtilsV2',
    clientCallable: true,
    accessibleFrom: 'public',
    script: `
var HRLXProLeaveUtilsV2 = Class.create();
HRLXProLeaveUtilsV2.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    calculateBusinessDays: function(startDate, endDate) {
        var count = 0;
        var gdt = new GlideDateTime(startDate);
        var end = new GlideDateTime(endDate);
        while (gdt.onOrBefore(end)) {
            var day = gdt.getDayOfWeekLocalTime();
            if (day != 1 && day != 7) count++;
            gdt.addDaysLocalTime(1);
        }
        return count;
    },
    type: 'HRLXProLeaveUtilsV2'
});
`
});