---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# OCRotationV2 - Global

# OCRotationV2 - Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The OCRotationV2 script include is an extension of OCRotation script include, which is used by Fullcalendar.io and the DHTMLX On-Call Calendar.

Use this script include to obtain the schedule time span between two dates that are further filtered by groups, rotas, rosters, and users. You can also extend OCRotationV2 to add or modify behavior. This is part
of On-Call Scheduling.

## OCRotationV2 - getGroups() {#ariaid-title2}

Returns an array of groups that have active rotas.
{#r_OCRotationV2-getGroups__table_ozg_nlb_h5__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#r_OCRotationV2-getGroups__table_ozg_nlb_h5} {#r_OCRotationV2-getGroups__table_pzg_nlb_h5__entry__2}

| Type | Description |
|-|-|
| Array | An array of group objects. Each contains the following attributes: * sys_id of the sys_user_group record * name of the sys_user_group record {#r_OCRotationV2-getGroups__ul_brf_31x_55} |
[Table 2. Returns]

{#r_OCRotationV2-getGroups__table_pzg_nlb_h5}

## OCRotationV2 - getRostersByRotas(String rotaSysIds) {#ariaid-title3}

Returns an array of active rosters for a given rota ID.
{#r_OCRotationV2-getRostersByRotas_String__table_y14_1mb_h5__entry__3}

| Name | Type | Description |
|-|-|-|
| rotaSysIds | String | Comma separated list of rota sys_id (cmn_rota) values. |
[Table 3. Parameters]

{#r_OCRotationV2-getRostersByRotas_String__table_y14_1mb_h5} {#r_OCRotationV2-getRostersByRotas_String__table_z14_1mb_h5__entry__2}

| Type | Description |
|-|-|
| Array | An array of rota objects. Each contains the following attributes: * sys_id of the cmn_rota_roster record * name of the cmn_rota_roster record * rota sys_id of the cmn_rota record {#r_OCRotationV2-getRostersByRotas_String__ul_svs_y1x_55} |
[Table 4. Returns]

{#r_OCRotationV2-getRostersByRotas_String__table_z14_1mb_h5}

## OCRotationV2 - getRotasByGroup(String groupSysIds) {#ariaid-title4}

Returns an array of active rotas for a given group ID.
{#r_OCRotationV2-getRotasByGroup_String__table_jcg_xlb_h5__entry__3}

| Name | Type | Description |
|-|-|-|
| groupSysIds | String | Comma separated list of group sys_id (sys_user_group) values. |
[Table 5. Parameters]

{#r_OCRotationV2-getRotasByGroup_String__table_jcg_xlb_h5} {#r_OCRotationV2-getRotasByGroup_String__table_kcg_xlb_h5__entry__2}

| Type | Description |
|-|-|
| Array | An array of rota objects. Each contains the following attributes: * sys_id of the cmn_rota record * name of the cmn_rota record * group sys_id of the sys_user_group record {#r_OCRotationV2-getRotasByGroup_String__ul_plv_p1x_55} |
[Table 6. Returns]

{#r_OCRotationV2-getRotasByGroup_String__table_kcg_xlb_h5}

## OCRotationV2 - getSpans() {#ariaid-title5}

Get the spans from the specified start date to the specified end date. If no start and
end dates are provided, the start date defaults to a month before and the end date defaults to a
month after the current time. You can also use the groups IDs, rota IDs, roster IDs, user IDs to
further filter the spans.
{#r_OCRotationV2-getSpans__table_j24_jlb_h5__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 7. Parameters]

{#r_OCRotationV2-getSpans__table_j24_jlb_h5} {#r_OCRotationV2-getSpans__table_k24_jlb_h5__entry__2}

| Type | Description |
|-|-|
| Array | An array of spans. Each contains the following attributes: id, sys_id, table, rota_id, roster_id, user_id, text, description, color, textColor, start_date, end_date. |
[Table 8. Returns]

{#r_OCRotationV2-getSpans__table_k24_jlb_h5}  
Get all spans for the default time period

    var spans = new OCRotationV2().getSpans();
    var firstSpanStartDate = spans[0].start_date; // get the first span's start date

Get all spans between 1st April 2014 and 5th June 2014

    var spans = new OCRotationV2()
        .setStartDate("2014-04-01")
        .setEndDate("2014-06-05")
        .getSpans();

Get the Network group's spans for the default time period

    var spans = new OCRotationV2()
         .setGroupIds("287ebd7da9fe198100f92cc8d1d2154e")
         .getSpans();

Get ITIL User's spans between 1st January 2014 and 31st January 2014

    var spans = new OCRotationV2()
        .setStartDate("2014-01-01")
        .setEndDate("2014-01-31")
        .setUserIds("681b365ec0a80164000fb0b05854a0cd")
        .getSpans();


