Copy this script into ServiceNow under application x_786686_hr_leave (Australia). Table/API names already use the current scope.
Source: src/portal/widgets/hrlx_my_leaves/client.js
/**
* Widget: hrlx_my_leaves — Client Controller
* Application: Custom · Scope: x_786686_hr_leave · sys_id: c84db0e8839f0b509f02b0d6feaad3c9
*/
function HrlxMyLeavesCtrl() {
var c = this;
c.cancelLeave = function (item) {
if (!confirm('Cancel leave ' + item.number + '?')) return;
c.data.action = 'cancel';
c.data.sys_id = item.sys_id;
c.server.update().then(function () {
c.data.action = '';
c.data.sys_id = '';
});
};
}