Create Alternating Work Schedules

You can use Oracle Field Service REST APIs to create alternate work schedules for resources.

Let's look at an example to understand this.

You want to create work schedules for John Smith, a field technician in your company, whose work schedule changes every other week. Suppose his work schedule is as follows:

  • For the first week (Week 1), he works from Monday through Thursday, for 10 hours a day.
  • For the next week (Week 2), he works from Tuesday through Friday, for 10 hours a day.

In this case, you need to make two separate API calls to create the work schedules.

Create work schedule for Week 1

You can create the work schedule using the 'Set a work schedule' operation as follows:

  1. Construct the request URL for the 'Set a work schedule' operation.
  2. Construct the request body with these parameters:
    • recurrenceType: weekly
    • recurEvery: 2
    • weekdays: ["Mon", "Tue", "Wed", "Thu"]
  3. Run the request using the POST HTTP method.

Example URL

Here's the complete URL with the POST HTTP method.

POST 
https://<instance_name>.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/44040/workSchedules

Example Request

Here's an example of the request body in JSON format.

{
   "recordType": "working",
   "startDate":  "2018-01-22",
   "workTimeStart": "12:00:00",
   "workTimeEnd": "22:00:00",
   "shiftType": "regular",
   "recurrence": {
       "recurrenceType": "weekly",
       "recurEvery": 2,
       "weekdays": ["Mon", "Tue", "Wed", "Thu"]
   }
}

Example Response

Here's an example response body in JSON format.

{
    "items": [
        {
            "recordType": "working",
            "startDate": "2019-09-05",
            "shiftType": "regular",
            "workTimeStart": "12:00:00",
            "workTimeEnd": "22:00:00",
            "isWorking": true,
            "scheduleItemId": 24935,
            "recurrence": {
                "recurrenceType": "weekly",
                "recurEvery": 2,
                "weekdays": [
                    "Mon",
                    "Tue",
                    "Wed",
                    "Thu"
                ]
            }
        },
        {
            "recordType": "schedule",
            "startDate": "2011-01-30",
            "scheduleLabel": "on-call",
            "scheduleItemId": 1040,
            "scheduleShifts": [
                {
                    "recordType": "shift",
                    "startDate": "2011-01-30",
                    "scheduleLabel": "on-call",
                    "shiftLabel": "on-call",
                    "shiftType": "on-call",
                    "workTimeStart": "08:00:00",
                    "workTimeEnd": "22:00:00",
                    "isWorking": true,
                    "recurrence": {
                        "recurrenceType": "everyday"
                    }
                }
            ]
        }
    ],
    "totalResults": 2,
    "links": [
        {
            "rel": "canonical",
            "href": "https://<instance_name>.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/44040/workSchedules"
        },
        {
            "rel": "describedby",
            "href": "https://<instance_name>.fs.ocs.oraclecloud.com/rest/ofscCore/v1/metadata-catalog/resources"
        }
    ]
}

Create work schedule for Week 2

You can create the work schedule using the 'Set a work schedule' operation as follows:

  1. Construct the request URL for the 'Set a work schedule' operation.
  2. Construct the request body with these parameters:
    • recurrenceType: weekly
    • recurEvery: 2
    • weekdays: ["Tue", "Wed", "Thu", "Fri"]
  3. Run the request using the POST HTTP method.

Example URL

Here's the complete URL with the POST HTTP method.

POST 
https://<instance_name>.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/44040/workSchedules

Example Request

Here's an example of the request body in JSON format.

{
   "recordType": "working",
   "startDate":  "2018-01-29",
   "workTimeStart": "08:00:00",
   "workTimeEnd": "18:00:00",
   "shiftType": "regular",
   "recurrence": {
       "recurrenceType": "weekly",
       "recurEvery": 2,
       "weekdays": ["Tue", "Wed", "Thu", "Fri"]
   }
}

Example Response

Here's an example response body in JSON format.

{
    "items": [
        {
            "recordType": "working",
            "startDate": "2019-09-05",
            "shiftType": "regular",
            "workTimeStart": "12:00:00",
            "workTimeEnd": "22:00:00",
            "isWorking": true,
            "scheduleItemId": 24935,
            "recurrence": {
                "recurrenceType": "weekly",
                "recurEvery": 2,
                "weekdays": [
                    "Mon",
                    "Tue",
                    "Wed",
                    "Thu"
                ]
            }
        },
        {
            "recordType": "working",
            "startDate": "2019-09-05",
            "shiftType": "regular",
            "workTimeStart": "08:00:00",
            "workTimeEnd": "18:00:00",
            "isWorking": true,
            "scheduleItemId": 24936,
            "recurrence": {
                "recurrenceType": "weekly",
                "recurEvery": 2,
                "weekdays": [
                    "Tue",
                    "Wed",
                    "Thu",
                    "Fri"
                ]
            }
        },
        {
            "recordType": "schedule",
            "startDate": "2011-01-30",
            "scheduleLabel": "on-call",
            "scheduleItemId": 1040,
            "scheduleShifts": [
                {
                    "recordType": "shift",
                    "startDate": "2011-01-30",
                    "scheduleLabel": "on-call",
                    "shiftLabel": "on-call",
                    "shiftType": "on-call",
                    "workTimeStart": "08:00:00",
                    "workTimeEnd": "22:00:00",
                    "isWorking": true,
                    "recurrence": {
                        "recurrenceType": "everyday"
                    }
                }
            ]
        }
    ],
    "totalResults": 3,
    "links": [
        {
            "rel": "canonical",
            "href": "https://<instance_name>.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/44040/workSchedules"
        },
        {
            "rel": "describedby",
            "href": "https://<instance_name>.fs.ocs.oraclecloud.com/rest/ofscCore/v1/metadata-catalog/resources"
        }
    ]
}