사용자의 교대 그룹을 기준으로 그룹 관리자 배열을 반환합니다.
표 7. 매개변수
| 이름 |
유형 |
설명 |
| rosterSpanProposalGr |
GlideRecord |
roster_schedule_span_proposal 기록입니다. |
표 8. 반환
| 유형 |
설명 |
| 배열 |
사용자의 순번 그룹을 기반으로 하는 그룹 관리자 배열입니다. |
다음 예제는 OCPTOApprovalReminder라는 주문형 스크립트 포함입니다. 예약된 작업을 수동으로 실행하여 호출하면 관리자 및 위임 관리자에게 다음 날 PTO가 예약된 직원에 대한 알림이 전송됩니다.
function OCPTOApprovalReminder() {
//Passing parameters in 'getDateFormat()' function with the days which needs to be added
var startDate = getDateFormat(1); //We can use System property to set Start Date
var endDate = getDateFormat(2); //We can use System property to set End Date
//Building the encoded query all the Pending approval state proposals whose start date is tomorrow
var encodedQuery = 'state=1^roster_schedule_span.start_date_time>' + startDate + '^roster_schedule_span.start_date_time<' + endDate;
//Sends an event notification to all rota managers and their delegate managers
getNotApprovedList(encodedQuery);
//Converts the date and time in ISO Format
function getDateFormat(daysToBeAdded) {
//Getting today's date and adding '1' day
var todaysDate = new GlideDate();
todaysDate.addDaysUTC(daysToBeAdded);
todaysDate = todaysDate.getValue();
//Converting to today's date object to GlideDate object
var addingDaysToDate = new GlideDate();
addingDaysToDate.setValue(todaysDate);
//Setting the time default to '12:00:00' and returning the time in the specified format to match ISO
var staticTime = new GlideTime();
staticTime.setValue('00:00:00');
staticTime.setValue(staticTime.getHourOfDayUTC() + ':' + staticTime.getMinutesUTC() + ':' + staticTime.getSeconds());
//Returns the date & time in the specified format
var isoFormattedDateTime = addingDaysToDate.getByFormat("yyyyMMdd") + 'T' + staticTime.getByFormat("HHmmss") + 'Z';
return isoFormattedDateTime;
}
//Gliding Roster schedule span proposal table with the built-in query to fetch the records whose proposals are not approved/rejected
function getNotApprovedList(addEncodedQuery) {
var rosterScheduleEntryProposalGR = new GlideRecord('roster_schedule_span_proposal');
rosterScheduleEntryProposalGR.addEncodedQuery(addEncodedQuery);
rosterScheduleEntryProposalGR.query();
while(rosterScheduleEntryProposalGR.next()) {
//Call On-Call Scheduling OCRosterSpanApprovalUtil library with 'getPTOApproversList' function
//pass GlideRecord object of 'roster_schedule_span_proposal' table
var rotaManagers = new OCRosterSpanApprovalUtil().getPTOApproversList(rosterScheduleEntryProposalGR);
rotaManagers = rotaManagers.join(",");
// Pull only the unique sys_ids
var managerList = new ArrayUtil().unique(getManagerDelegateApprovals(rotaManagers).toString().split(','));
// Event to trigger a reminder notification for testing.
// To use, create a an event registry named "oc.manager.delegate.reminder"
// Call the event in a notification and uncomment the following line
//gs.eventQueue("oc.manager.delegate.reminder", rosterScheduleEntryProposalGR, managerList, "");
if(managerList)
gs.info("Returns the list of manager and it's delegate members >>>>>> " + managerList);
}
}
//Get the sys_ids of the managers and their delegate managers
function getManagerDelegateApprovals(manager) {
var answer = [];
answer.push(manager);
var delegateGR = new GlideRecord("sys_user_delegate");
delegateGR.addQuery("user", 'IN', manager);
delegateGR.addQuery("starts", "<=", gs.daysAgo(0));
delegateGR.addQuery("ends", ">=", gs.daysAgo(0));
delegateGR.addQuery("approvals", true);
delegateGR.query();
while(delegateGR.next()) {
answer.push(delegateGR.getValue('user'));
answer.push(delegateGR.getValue('delegate'));
}
return answer;
}
}
예약된 스크립트 실행 [sysauto_script] 테이블의 기록에 다음 호출을 추가합니다. 이 트리거는 예약된 작업이 수동으로 실행될 때 OCPTOApprovalReminder 스크립트 포함을 호출합니다.
OCPTOApprovalReminder();