OAAS Class

Contains all the methods used in the available optimization services, such as global or in-day optimizations, reshuffle operations, and resource schedule optimizations.

FSL

If you call OAAS APIs, running asynchronously, from the following methods, you receive a Database.executeBatch exception error message.

  • start batch Apex method
  • execute batch Apex method
  • future methods

The limitation doesn’t apply if you’re using Enhanced Scheduling and Optimization. See Using Batch Apex & Future Methods in the Apex Developer Guide.

OAAS includes the following methods.

Returns the optimization request ID of the global optimization process that was triggered. If the scheduling policy includes an in-day optimization Boolean that’s set to true, the request triggers an in-day optimization.

public static Id optimize(FSL.OAASRequest request)

request

Type: FSL.OAASRequest

The optimization request.

Type: Id

Record ID of the optimization request.

This example creates an instance of the OAASRequest class that holds all the details of the optimization call being initiated. Next, the example calls the optimize method and passes in the request.

Returns the optimization request ID of a reshuffle operation that has begun on a given service appointment.

public static Id reshuffle(Id serviceId, Id policyId)

serviceId

Type: Id

The record ID of the service appointment that must be scheduled.

policyId

Type: Id

The record ID of the scheduling policy being used to schedule the service appointment.

Type: Id

Record ID of the optimization request.

The Reshuffle action is used when a high-priority service appointment must be scheduled within a full schedule. It runs a “mini-optimization” that attempts to reshuffle the schedule to accommodate the appointment.

To learn more about the Reshuffle action, see Reschedule Service Appointments.

Returns the optimization request ID with the details of the optimization call. This method runs resource schedule optimization—the optimization of a single service resource’s schedule—using the parameters provided.

public static Id resourceDayOptimization(Id resourceId, Id policyId, FSL.TimeInterval horizon, Boolean includeAllTasks, Boolean includeOnlyResourceFutureSA, Decimal radius, String candidateSasFields, String unschedulableServicesField, Decimal maxOptRuntime)

resourceId

Type: Id

The record ID of the service resource whose schedule is being optimized.

policyId

Type: Id

The record ID of the scheduling policy being used to schedule the service appointment.

horizon

Type: FSL.TimeInterval

The time frame used to run resource schedule optimization.

includeAllTasks

Type: Boolean

If true, all relevant service appointments within the time frame are considered during optimization. If false, only unscheduled service appointments are considered, and all scheduled service appointments are pinned (unmovable).

includeOnlyResourceFutureSA

Type: Boolean

If true, only service appointments that are already assigned to the service resource are considered during optimization. If false, service appointments assigned to other service resources are also considered.

radius

Type: Decimal

The suggested distance between required service appointments and adjacent appointments. Required appointments are defined by the unschedulableServicesField parameter. Resource schedule optimization tries to group service appointments so that their distance from a required appointment is less than this radius. Appointments that are further from a required appointment can still be scheduled, but are deprioritized. If null, the data is not filtered based on the radius.

candidateSasFields

Type: String

Boolean service appointment field that indicates which appointments are candidates to be scheduled.

unschedulableServicesField

Type: String

Boolean service appointment field that indicates whether a service appointment is required (pinned), meaning it must remain on the schedule during resource schedule optimization.

maxOptRuntime

Type: Decimal

Total time in seconds during which the optimization results must be returned. This parameter only enforces the optimization time, and does not include optimization queue or Apex job queue times. If null, the default value of 30 seconds is used.

To learn more about resource schedule optimization, see Optimize a Single Resource’s Schedule.

Type: Id

Record ID of the optimization request.

Returns the optimization request ID with the details of the optimization call. This method runs resource schedule optimization—the optimization of a single service resource’s schedule—using the parameters provided.

public static Id resourceDayOptimization(Id resourceId, Id policyId, FSL.TimeInterval horizon, Boolean includeAllTasks, Boolean includeOnlyResourceFutureSA, Decimal radius, String candidateSasFields, String unschedulableServicesField, Decimal maxOptRuntime, Datetime nowTimeOnSchedule)

resourceId

Type: Id

The record ID of the service resource whose schedule is being optimized.

policyId

Type: Id

The record ID of the scheduling policy being used to schedule the service appointment.

horizon

Type: FSL.TimeInterval

The time frame used to run resource schedule optimization.

includeAllTasks

Type: Boolean

If true, all relevant service appointments within the time frame are considered during optimization. If false, only unscheduled service appointments are considered, and all scheduled service appointments are pinned (unmovable).

includeOnlyResourceFutureSA

Type: Boolean

If true, only service appointments that are already assigned to the service resource are considered during optimization. If false, service appointments assigned to other service resources are also considered.

radius

Type: Decimal

The suggested distance between required service appointments and adjacent appointments. Required appointments are defined by the unschedulableServicesField and nowTimeOnSchedule parameters. Resource schedule optimization tries to group service appointments so that their distance from a required appointment is less than this radius. Appointments that are further from a required appointment can still be scheduled, but are deprioritized. If null, the data is not filtered based on the radius.

candidateSasFields

Type: String

Boolean service appointment field that indicates which appointments are candidates to be scheduled.

unschedulableServicesField

Type: String

Boolean service appointment field that indicates whether a service appointment is required (pinned), meaning it must it must remain on the schedule during resource schedule optimization.

maxOptRuntime

Type: Decimal

Total time in seconds during which the optimization results must be returned. This parameter only enforces the optimization time, and does not include optimization queue or Apex job queue times. If null, the default value of 30 seconds is used.

nowTimeOnSchedule

Type: Datetime

An appointment whose scheduled start time is earlier than this time is considered required and isn’t updated during resource schedule optimization. Because resource schedule optimization is asynchronous, this parameter indicates when optimization was initiated. For example, if nowTimeOnSchedule is set to April 17, 2018, 10:30, appointments with an earlier scheduled start time are considered required and excluded from resource schedule optimization.

Type: Id

Record ID of the optimization request.

To learn more about resource schedule optimization, see Optimize a Single Resource’s Schedule.

To use this code sample, replace the ID placeholders—for example, Service Appointment ID—with record IDs from your org. Surround the IDs with single quotes: '08p4E00000017Gq'.

Where SERVICE_APPOINTMENT_ID, SERVICE_RESOURCE_ID, and SCHEDULING_POLICY_ID are variables.

Returns the optimization request ID with the details of the optimization call. This method runs resource schedule optimization—the optimization of a single service resource’s schedule—using the parameters provided.

public static Id resourceDayOptimization(Id resourceId, Id policyId, FSL.TimeInterval horizon, Boolean includeAllTasks, Boolean includeOnlyResourceFutureSA, Decimal radius, Set<String> candidateSas, Set<String> unschedulableServices, Decimal maxOptRuntime)

resourceId

Type: Id

The record ID of the service resource whose schedule is being optimized.

policyId

Type: Id

The record ID of the scheduling policy being used to schedule the service appointment.

horizon

Type: FSL.TimeInterval

The time frame used to run resource schedule optimization.

includeAllTasks

Type: Boolean

If true, all relevant service appointments within the time frame are considered during optimization. If false, only unscheduled service appointments are considered, and all scheduled service appointments are pinned (unmovable).

includeOnlyResourceFutureSA

Type: Boolean

If true, only service appointments that are already assigned to the service resource are considered during optimization. If false, service appointments assigned to other service resources are also considered.

radius

Type: Decimal

The suggested distance between required service appointments and adjacent appointments. Required appointments are defined by the unschedulableServices parameter. Resource schedule optimization tries to group service appointments so that their distance from a required appointment is less than this radius. Appointments that are further from a required appointment can still be scheduled, but are deprioritized. If null, the data is not filtered based on the radius.

candidateSas

Type: Set<Id>

Set of IDs of service appointments that are candidates for scheduling.

unschedulableServices

Type: Set<Id>

Set of IDs of service appointments that are required (pinned), meaning they must remain on the schedule during resource schedule optimization

maxOptRuntime

Type: Decimal

Total time in seconds during which the optimization results must be returned. This parameter only enforces the optimization time, and does not include optimization queue or Apex job queue times. If null, the default value of 30 seconds is used.

To learn more about resource schedule optimization, see Optimize a Single Resource’s Schedule.

Type: Id

Record ID of the optimization request.

Returns the optimization request ID with the details of the optimization call. This method runs resource schedule optimization—the optimization of a single service resource’s schedule—using the parameters provided.

public static Id resourceDayOptimization(Id resourceId, Id policyId, FSL.TimeInterval horizon, Boolean includeAllTasks, Boolean includeOnlyResourceFutureSA, Decimal radius, Set<String> candidateSas, Set<String> unschedulableServices, Decimal maxOptRuntime, Datetime nowTimeOnSchedule)

resourceId

Type: Id

The record ID of the service resource whose schedule is being optimized.

policyId

Type: Id

The record ID of the scheduling policy being used to schedule the service appointment.

horizon

Type: FSL.TimeInterval

The time frame used to run resource schedule optimization.

includeAllTasks

Type: Boolean

If true, all relevant service appointments within the time frame are considered during optimization. If false, only unscheduled service appointments are considered, and all scheduled service appointments are pinned (unmovable).

includeOnlyResourceFutureSA

Type: Boolean

If true, only service appointments that are already assigned to the service resource are considered during optimization. If false, service appointments assigned to other service resources are also considered.

radius

Type: Decimal

The suggested distance between required service appointments and adjacent appointments. Required appointments are defined by the unschedulableServices and nowTimeOnSchedule parameters. Resource schedule optimization tries to group service appointments so that their distance from a required appointment is less than this radius. Appointments that are further from a required appointment can still be scheduled, but are deprioritized. If null, the data is not filtered based on the radius.

candidateSas

Type: Set<Id>

Set of IDs of service appointments that are candidates for scheduling.

unschedulableServices

Type: Set<Id>

Set of IDs of service appointments that are required, meaning they must remain on the schedule during resource schedule optimization. These appointments may be moved to a different time slot, but they will continue to comply with their Earliest Start Permitted and Due Date values.

maxOptRuntime

Type: Decimal

Total time in seconds during which the optimization results must be returned. This parameter only enforces the optimization time, and does not include optimization queue or Apex job queue times. If null, the default value of 30 seconds is used.

nowTimeOnSchedule

Type: Datetime

Optional. An appointment whose scheduled start time is earlier than this time is considered required and isn’t updated during resource schedule optimization. Because resource schedule optimization is asynchronous, this parameter indicates when optimization was initiated. For example, if nowTimeOnSchedule is set to April 17, 2018, 10:30, appointments with an earlier scheduled start time are considered required and excluded from resource schedule optimization.

Type: Id

Record ID of the optimization request.

To learn more about resource schedule optimization, see Optimize a Single Resource’s Schedule.