---
sourceDocument: Référence de l’API Xanadu
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/fr-FR/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - fr-FR

ft:publication_title :

    - Référence de l’API Xanadu

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# OCRosterSpanApprovalUtil : global

# OCRosterSpanApprovalUtil : global {#ariaid-title1}

L'include de script OCRosterSpanApprovalUtil fournit des méthodes pour la fonctionnalité d'approbation des congés payés.

## OCRosterSpanApprovalUtil : approvePTOSpan (GlideRecord rosterSpanGr) {#ariaid-title2}

Modifie le type de roster_schedule_span à congé à partir de l'approbation.
{#r_OCRosSpnApUtil-approvePTOSpan_GR__table_q5p_l1j_hx__entry__3}

| Nom | Type | Description |
|-|-|-|
| rosterSpanGr | GlideRecord | Un enregistrement roster_schedule_span_proposal. |
[Tableau 1. Paramètres]

{#r_OCRosSpnApUtil-approvePTOSpan_GR__table_q5p_l1j_hx} {#r_OCRosSpnApUtil-approvePTOSpan_GR__table_r5p_l1j_hx__entry__2}

| Type | Description |
|-|-|
| nul |   |
[Tableau 2. Renvoie]

{#r_OCRosSpnApUtil-approvePTOSpan_GR__table_r5p_l1j_hx}

## OCRosterSpanApprovalUtil : getContextualCalUrlPerSpanProposal (GlideRecord rosterSpanProposalGr) {#ariaid-title3}

Renvoie une URL au calendrier d'astreinte en fonction de rosterSpanProposalGr.
{#r_OCRosSpnApUtil-gtCtCalUrlPrSnP_GR__table_xhy_cy3_hx__entry__3}

| Nom | Type | Description |
|-|-|-|
| rosterSpanProposalGr | GlideRecord | Un enregistrement roster_schedule_span_proposal. |
[Tableau 3. Paramètres]

{#r_OCRosSpnApUtil-gtCtCalUrlPrSnP_GR__table_xhy_cy3_hx} {#r_OCRosSpnApUtil-gtCtCalUrlPrSnP_GR__table_yhy_cy3_hx__entry__2}

| Type | Description |
|-|-|
| Chaîne | URL vers le calendrier d'astreinte en fonction de rosterSpanProposalGr. |
[Tableau 4. Renvoie]

{#r_OCRosSpnApUtil-gtCtCalUrlPrSnP_GR__table_yhy_cy3_hx}

## OCRosterSpanApprovalUtil : getFromDateDisplayValuePerSpanProposal (GlideRecord rosterSpanProposalGr) {#ariaid-title4}

Renvoie une chaîne GlideScheduleDateTime formatée en fonction de la date de début de rosterSpanProposalGr.
{#r_OCRosSpnApUtil-gtFrDtDpVlPSPrp_GR__table_f5s_gz3_hx__entry__3}

| Nom | Type | Description |
|-|-|-|
| rosterSpanProposalGr | GlideRecord | Un enregistrement roster_schedule_span_proposal. |
[Tableau 5. Paramètres]

{#r_OCRosSpnApUtil-gtFrDtDpVlPSPrp_GR__table_f5s_gz3_hx} {#r_OCRosSpnApUtil-gtFrDtDpVlPSPrp_GR__table_g5s_gz3_hx__entry__2}

| Type | Description |
|-|-|
| Chaîne | Une chaîne GlideScheduleDateTime formatée basée sur la date de début de rosterSpanProposalGr. |
[Tableau 6. Renvoie]

{#r_OCRosSpnApUtil-gtFrDtDpVlPSPrp_GR__table_g5s_gz3_hx}

## OCRosterSpanApprovalUtil : getPTOApproversList(GlideRecord rosterSpanProposalGr) {#ariaid-title5}

Renvoie un tableau des gestionnaires de groupes basés sur les groupes de rotation de l'utilisateur.
{#r_OCRosSpnApUtil-getPTOApprList_GR__table_m5z_tx3_hx__entry__3}

| Nom | Type | Description |
|-|-|-|
| rosterSpanProposalGr | GlideRecord | Un enregistrement roster_schedule_span_proposal. |
[Tableau 7. Paramètres]

{#r_OCRosSpnApUtil-getPTOApprList_GR__table_m5z_tx3_hx} {#r_OCRosSpnApUtil-getPTOApprList_GR__table_n5z_tx3_hx__entry__2}

| Type | Description |
|-|-|
| Tableau | Tableau des gestionnaires de groupes basés sur les groupes de rotation de l'utilisateur. |
[Tableau 8. Renvoie]

{#r_OCRosSpnApUtil-getPTOApprList_GR__table_n5z_tx3_hx}  
L'exemple suivant est un include de script à la demande nommé OCPTOApprovalReminder. Lorsqu'ils sont appelés en exécutant manuellement la tâche planifiée, les gestionnaires et leurs gestionnaires délégués sont informés des employés dont le PTO est planifié le lendemain.

    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;
    	}
    }

Ajoutez l'appel suivant à un enregistrement dans la table Exécution de script planifiée \[sysauto_script\]. Ce déclencheur appelle l'include de script OCPTOApprovalReminder lorsque la tâche planifiée est exécutée manuellement.

    OCPTOApprovalReminder();

## OCRosterSpanApprovalUtil : getToDateDisplayValuePerSpanProposal (rosterSpanProposalGr, GlideRecord) {#ariaid-title6}

Renvoie une chaîne GlideScheduleDateTime formatée en fonction de la date de fin de rosterSpanProposalGr.
{#r_OCRosSpnApUtil-gtToDtDVlPrSnPr_GR__table_jbs_21j_hx__entry__3}

| Nom | Type | Description |
|-|-|-|
| rosterSpanProposalGr | GlideRecord | Un enregistrement roster_schedule_span_proposal. |
[Tableau 9. Paramètres]

{#r_OCRosSpnApUtil-gtToDtDVlPrSnPr_GR__table_jbs_21j_hx} {#r_OCRosSpnApUtil-gtToDtDVlPrSnPr_GR__table_kbs_21j_hx__entry__2}

| Type | Description |
|-|-|
| Chaîne | Une chaîne GlideScheduleDateTime formatée basée sur la date de fin de rosterSpanProposalGr. |
[Tableau 10. Renvoie]

{#r_OCRosSpnApUtil-gtToDtDVlPrSnPr_GR__table_kbs_21j_hx}

## OCRosterSpanApprovalUtil : getUserNamePerSpanProposal (GlideRecord rosterSpanProposalGr) {#ariaid-title7}

Renvoie le nom de l'utilisateur en fonction de rosterSpanProposalGr.
{#r_OCRosSpnApUtil-gtUNmPerSnProp_GR__table_rpb_ly3_hx__entry__3}

| Nom | Type | Description |
|-|-|-|
| rosterSpanProposalGr | GlideRecord | Un enregistrement roster_schedule_span_proposal. |
[Tableau 11. Paramètres]

{#r_OCRosSpnApUtil-gtUNmPerSnProp_GR__table_rpb_ly3_hx} {#r_OCRosSpnApUtil-gtUNmPerSnProp_GR__table_spb_ly3_hx__entry__2}

| Type | Description |
|-|-|
| Chaîne | Nom de l'utilisateur basé sur rosterSpanProposalGr. |
[Tableau 12. Renvoie]

{#r_OCRosSpnApUtil-gtUNmPerSnProp_GR__table_spb_ly3_hx}

## OCRosterSpanApprovalUtil : isPTOApprovalRequired () {#ariaid-title8}

Vérifie si la propriété com.snc.on_call_rotation.pto.approval.required système est définie sur vrai.
{#r_OCRosSpnApUtil-isPTOAppRequired__table_ift_lx3_hx__entry__3}

| Nom | Type | Description |
|-|-|-|
| Aucun |   |   |
[Tableau 13. Paramètres]

{#r_OCRosSpnApUtil-isPTOAppRequired__table_ift_lx3_hx} {#r_OCRosSpnApUtil-isPTOAppRequired__table_jft_lx3_hx__entry__2}

| Type | Description |
|-|-|
| Booléen | Renvoie la valeur true si la propriété com.snc.on_call_rotation.pto.approval.required système est true. |
[Tableau 14. Renvoie]

{#r_OCRosSpnApUtil-isPTOAppRequired__table_jft_lx3_hx}

## OCRosterSpanApprovalUtil : rejectPTOSpan (rosterSpanGr, GlideRecord) {#ariaid-title9}

Modifie le type de la roster_schedule_span en rejeté à partir de l'approbation.
{#r_OCRosSpnApUtil-rejectPTOSpan_GR__table_vvb_t1j_hx__entry__3}

| Nom | Type | Description |
|-|-|-|
| rosterSpanGr | GlideRecord | Un enregistrement roster_schedule_span_proposal. |
[Tableau 15. Paramètres]

{#r_OCRosSpnApUtil-rejectPTOSpan_GR__table_vvb_t1j_hx} {#r_OCRosSpnApUtil-rejectPTOSpan_GR__table_wvb_t1j_hx__entry__2}

| Type | Description |
|-|-|
| nul |   |
[Tableau 16. Renvoie]

{#r_OCRosSpnApUtil-rejectPTOSpan_GR__table_wvb_t1j_hx}

