Bulk update resource work schedules
/rest/ofscCore/v1/resources/custom-actions/bulkUpdateWorkSchedules
This operation creates, updates, or deletes work schedules of multiple resources in a single call.
Error Handling:
- If the request size is greater than 5 MB, then the operation fails with the HTTP status '413 Request entity too large' error.
- If the request body in JSON is invalid in terms of the swagger schema, then the operation fails with the HTTP status '400 Bad Request' error. The error details are as follows:
- Invalid property value. Path: 'path_in_swagger_shema'. Value: 'error_value'. Valid values: 'some_valid_value_1','some_valid_value_N'.
- If both the parameters 'resourceId' and 'resourceInternalId' are specified in a request, then the operation fails with the HTTP status '400 Bad Request' error. The error details are as follows:
- Only one of the parameters 'resourceId' or 'resourceInternalId' can be specified in a request.
- If the parameters 'resourceId' and 'resourceInternalId' are missing in the request item, then the operation fails with the HTTP status '400 Bad Request' error. The error details are as follows:
- Mandatory property is absent: 'resourceId' or 'resourceInternalId' must be defined.
- If the swagger validation fails, then the operation fails with the HTTP status '400 Bad Request' error. Examples of such cases are:
- A required field is not specified.
- The request is not a valid JSON.
- The operation returns HTTP status '200 OK', even if some work schedules are not updated or some resources specified in the request are invalid. Verify the response to identify the operations that succeeded and the operations that failed. The following is an example of such case:
- The resourceId does not exist.
Permissions:
The permission 'core_api_resource' has to be set to 'ReadWrite' for this API to work.
Request
arrayBulk Update Resource Work Schedules Schema-
Array of:
object Work Schedule
Title:
Work ScheduleAn object containing a work schedule item.
objectWork Schedule-
resourceId:
string
Title:
Resource IDMinimum Length:1Maximum Length:32The identifier of the resource in the external system.Note: Only one of the following properties must be specified:
- resourceId
- resourceInternalId
-
resourceInternalId:
integer
Title:
Resource Internal IDMinimum Value:1The unique identifier of the resource in Oracle Field Service.Note: Only one of the following properties must be specified:
- resourceId
- resourceInternalId
-
workSchedules(required):
array Items
Title:
ItemsAn array of work schedule items.
arrayItems-
Array of:
object Resource Work Schedule Item
Title:
Resource Work Schedule ItemThe array of work schedule item of the resource.
objectResource Work Schedule Item-
comments:
string
Title:
CommentsThe description of the schedule in Oracle Field Service. -
endDate:
string(date)
Title:
End DateThe date when this schedule ends. The date is in 'YYYY-MM-DD' format. -
isWorking:
boolean
Title:
Is Working ShiftContains one of the following values: true or false. If true, then it is a working day. If false, then it is a non-working day.This is a read-only field calculated based on the record type or the shift settings.
-
nonWorkingReason:
string
Title:
Non-working ReasonThe reason for the non-working day (for example, holiday, vacation). These reasons are preconfigured in the Oracle Field Service UI. -
points:
integer
Title:
PointsThe units of labor per day when this schedule is in effect. This property may be empty because all the customers may not use it. -
recordType(required):
string
Title:
Record TypeAllowed Values:[ "schedule", "shift", "extra_shift", "working", "extra_working", "non-working" ]The type of work schedule record. -
recurrence:
object Recurrence
Title:
RecurrenceAn array containing recurring work schedule items. This object is optional when the recordType is schedule. And it is mandatory when the recordType is shift, extra_shift, working, extra_working or non-working -
scheduleItemId:
integer
Title:
Work Schedule Item IDThe identifier of the work schedule item in Oracle Field Service. -
scheduleLabel:
string
Title:
Work Schedule LabelThe label of the work schedule in Oracle Field Service. This property is only available if the record type is schedule. -
scheduleShifts:
array Shifts
Title:
ShiftsThe list of work shifts present in this work schedule. The properties of the work shifts are for information purpose only and cannot be modified using this operation. -
shiftLabel:
string
Title:
Work Shift LabelThe label of the work shift in Oracle Field Service. This property is only available if the value of recordType is either shift or extra_shift. -
shiftType:
string
Title:
Shift TypeAllowed Values:[ "regular", "on-call" ]The type of the work shift. -
startDate(required):
string(date)
Title:
Start DateThe date when this schedule takes effect. The format is 'YYYY-MM-DD'. -
workTimeEnd:
string(time)
Title:
Work Time EndThe end time of the working day when this schedule is in effect. The format is 'HH:MM'. This property is not available if the value of the isWorking parameter is false. -
workTimeStart:
string(time)
Title:
Work Time StartThe start time of the working day when this schedule is in effect. The format is 'HH:MM'. This property is not available if the value of the isWorking parameter is false.
objectRecurrence-
dayFrom:
string
Title:
Day FromThe start day (in 'YYYY-MM-DD' format) of the schedule period applicable for each year, when the schedule is in effect. It is used only if the recurrence type is yearly. -
dayTo:
string
Title:
Day ToThe end day (in 'YYYY-MM-DD' format) of the schedule period applicable for each year, when the schedule is in effect. It is used only if the recurrence type is yearly. -
recurEvery:
integer
Title:
Recur EveryMinimum Value:1Maximum Value:255The time between each recurrence of the work schedule. Depending on the value selected for 'recurrence', the value of the parameter indicates the time between recurrence in days or weeks. For example, if '4' is the value of this parameter, and the 'recurrence' is 'daily', it indicates that the time between each recurrence is four days. -
recurrenceType(required):
string
Title:
Recurrence TypeAllowed Values:[ "daily", "weekly", "yearly", "everyday" ]The type of the recurrence. This property along with the 'recurEvery' property defines the time between each recurrence. For example, if the value of this property is 'daily' and the value of the property 'recurEvery' is '4', then the time between each recurrence is four days. -
weekdays:
array Recurrence Weekdays
Title:
Recurrence WeekdaysThe weekdays on which the work shift recurs.
arrayShifts-
Array of:
object Resource Shift Item
Title:
Resource Shift ItemAn object containing the resource shift item.
arrayRecurrence Weekdays-
Array of:
string
Title:
WeekdayAllowed Values:[ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]The weekday on which the work shift recurs. This field is required only if the recurrence type is weekly.
objectResource Shift Item-
comments:
string
Title:
CommentsThe description of this shift in Oracle Field Service. -
endDate:
string(date)
Title:
End DateThe date when this shift ends. The date is in 'YYYY-MM-DD' format. -
isWorking:
boolean
Title:
Is Working ShiftContains one of the following values: true or false. If true, then it is a working day. If false, then it is a non-working day.This is a read-only field calculated based on the record type or the shift settings.
-
nonWorkingReason:
string
Title:
Non-working ReasonThe reason for the non-working day (for example, holiday, vacation). These reasons are preconfigured in the Oracle Field Service UI. -
points:
integer
Title:
PointsThe units of labor per day when this schedule is in effect. This property may be empty because all the customers may not use it. -
recordType:
string
Title:
Record TypeAllowed Values:[ "shift", "extra_shift" ]The type of the work shift record. -
recurrence:
object Recurrence
Title:
RecurrenceAn array containing recurring work schedule items. For repeating shifts this property contains a description of how the shift repeats over time. -
scheduleItemId:
integer
Title:
Work Schedule Item IDThe identifier of the work schedule item in Oracle Field Service. -
scheduleLabel:
string
Title:
Work Schedule LabelThe label of the work schedule in Oracle Field Service. This property is only available for the record type schedule. -
shiftLabel:
string
Title:
Work Shift LabelThe label of the work shift in Oracle Field Service. This property is only available if the record type is either shift or extra_shift. -
shiftType:
string
Title:
Shift TypeAllowed Values:[ "regular", "on-call" ]The type of the work shift. -
startDate:
string(date)
Title:
Start DateThe date when this shift takes effect. The date is in 'YYYY-MM-DD'. -
workTimeEnd:
string(time)
Title:
Work Time EndThe end time of a working day when this work shift is in effect. The format is HH:MM. This property is not available if the value of the isWorking parameter is false. -
workTimeStart:
string(time)
Title:
Work Time StartThe start time of a working day when this work shift is in effect. The format is HH:MM. This property is not available if the value of the isWorking parameter is false.
objectRecurrence-
dayFrom:
string
Title:
Day FromThe start day (in 'YYYY-MM-DD' format) of the schedule period applicable for each year, when the schedule is in effect. It is used only if the recurrence type is yearly. -
dayTo:
string
Title:
Day ToThe end day (in 'YYYY-MM-DD' format) of the schedule period applicable for each year, when the schedule is in effect. It is used only if the recurrence type is yearly. -
recurEvery:
integer
Title:
Recur EveryMinimum Value:1Maximum Value:255The time between each recurrence of the work shift. Depending on the value selected for 'recurrence', the value of the parameter indicates the time between recurrence in days or weeks. For example, if '4' is the value of this parameter, and the 'recurrence' is 'daily', it indicates that the time between each recurrence is four days. -
recurrenceType:
string
Title:
Recurrence TypeAllowed Values:[ "daily", "weekly", "yearly", "everyday" ]The type of the recurrence. This property along with the 'recurEvery' property defines the time between each recurrence. For example, if the value of this property is 'daily' and the value of the property 'recurEvery' is '4', then the time between each recurrence is four days. -
weekdays:
array Recurrence Weekdays
Title:
Recurrence WeekdaysThe weekdays on which the work schedule recurs.
arrayRecurrence Weekdays-
Array of:
string
Title:
WeekdayAllowed Values:[ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]The weekday on which the work schedule recurs.
Response
- application/json
200 Response
objectResource Work Schedules Bulk Update Schema-
resourcesUpdated:
integer
Title:
Resources UpdatedThe number of resources for which the work schedules are updated. -
results:
array Results
Title:
ResultsAn array containing the results of the operation.
arrayResults-
Array of:
object Result Item
Title:
Result ItemAn object containing a single result item.
objectResult Item-
errors:
array Errors
Title:
ErrorsThe errors that occurred while updating the work schedules of resources. -
itemsFailed:
integer
Title:
Items FailedThe number of failed work schedule updates. -
itemsUpdated:
integer
Title:
Items UpdatedThe number of updated work schedules for the resource. -
resourceId:
string
Title:
Resource IDThe unique identifier of the resource in Oracle Field Service.
arrayErrorsobject-
detail:
string
The detailed description of this error.
-
status:
string
The HTTP status code of this error.
-
title(required):
string
The brief description of this error.
-
type(required):
string
The URL of the web page containing more details about this error.
Default Response
object-
detail:
string
The detailed description of this error.
-
status:
string
The HTTP status code of this error.
-
title(required):
string
The brief description of this error.
-
type(required):
string
The URL of the web page containing more details about this error.
Examples
The following example shows how to bulk update resource work schedules by submitting a POST request on the REST resource using cURL:
cURL command Example
curl -s -u "<CLIENT-ID>@<INSTANCE-NAME>:<CLIENT-SECRET>" --url "https://<instance_name>.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/custom-actions/bulkUpdateWorkSchedules" -X POST -d '[
{
"resourceId": "test_bucket",
"workSchedules": [
{
"recordType": "working",
"startDate": "2018-04-16",
"endDate": "2018-04-17",
"workTimeStart": "10:00:00",
"workTimeEnd": "22:00:00",
"shiftType": "regular",
"recurrence": {
"recurrenceType": "weekly",
"recurEvery": 5
},
"comment": "default test_bucket resources work schedule"
},
{
"recordType": "schedule",
"startDate": "2018-04-16",
"endDate": "2018-04-17",
"scheduleLabel": "On-call+2nd"
},
{
"startDate": "2018-04-16",
"endDate": "2018-04-17",
"recordType": "non-working",
"scheduleLabel": "On-call+2nd",
"nonWorkingReason": "day-off"
},
{
"recordType": "schedule",
"startDate": "2018-04-16",
"endDate": "2018-04-17",
"scheduleLabel": "PAR-2nd/ODD-1st"
}
]
},
{
"resourceId": "test_tech",
"workSchedules": [
{
"startDate": "2018-04-16",
"endDate": "2018-04-17",
"recordType": "schedule",
"scheduleLabel": "PAR2nd/ODD-1st"
}
]
}
]'
Response Header Example
The following shows an example of the response header.
HTTP/1.1 200 OK Server: nginx/1.2.7 Date: Wed, 27 Jun 2018 12:44:50 GMT Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive
Response Body Example
The following shows an example of the response body in JSON format.
{
"resourcesUpdated" : 1,
"results" : [
{
"resourceId": "resource1",
"itemsUpdated" : 3,
"itemsFailed": 1,
"errors": [
{
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
"title": "Bad request",
"status": "400",
"detail": "Invalid schedule label \"PAR2nd/ODD-1st\""
},
{
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
"title": "Bad Request",
"status": "400",
"detail": "Required property not set. Entity: Resource Work Schedule, Property: shiftType"
}
]
},
{
"resourceId": "resource2",
"itemsUpdated" : 0,
"itemsFailed": 1,
"errors":[{
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
"title": "Bad request",
"status": "400",
"detail": "Invalid schedule label \"PAR2nd/ODD-1st\""
}]
},
{
"resourceId": "resource3",
"itemsUpdated" : 3,
"itemsFailed": 0
}
]
}