Newer Version Available

This content describes an older version of this product. View Latest

ScheduleService Class

Represents the scheduling of a given service appointment in the best available slot based on the applied scheduling policy.

Namespace

FSL

Usage

This class calls the scheduling engine and schedules the given service appointment in the highest-scoring available slot.

ScheduleService Methods

ScheduleService includes the following static methods.

schedule(policy, serviceId)

Returns FSL.ScheduleResult with the result of the scheduling process.

Signature

public static FSL.ScheduleResult schedule(Id policy, Id serviceId)

Parameters

policy
Type: Id
The record ID of the scheduling policy being used to schedule the service appointment.
serviceId
Type: Id
The record ID of the service appointment being scheduled.

Return Value

Type: FSL.ScheduleResult

Usage

This method schedules the service appointment in the best available slot. If there are no available slots, the appointment isn’t scheduled. This method can be called with only one service appointment at a time. To schedule multiple service appointments, use an Apex batch class. Call this method in batches of one.

If you are using the schedule method with the appointment booking method, perform a time zone conversion. The results of appointment booking are returned in the time zone specified in the method signature. Convert these values back to UTC.

Example

1// FSL.ScheduleService class
2// The Schedule method returns a ScheduleResult result
3FSL.ScheduleResult myResult = new FSL.ScheduleResult();
4
5// static FSL.ScheduleResult Schedule(Scheduling Policy ID, Service Appointment ID)
6myResult = FSL.ScheduleService.schedule(Scheduling Policy ID,Service Appointment ID);
7
8System.debug(myResult);

scheduleExtended(policy, serviceId)

Returns FSL.ScheduleResult with the result of the scheduling process for appointments in a complex work chain.

Signature

public static FSL.ScheduleResult scheduleExtended(Id policy, Id serviceId)

Parameters

policy
Type: Id
The record ID of the scheduling policy that’s used to schedule the service appointment.
serviceId
Type: Id
The record ID of a service appointment in a complex work chain of two appointments that are being scheduled.

Return Value

Type: FSL.ScheduleResult

Usage

Use this method to schedule two service appointments in a complex work chain. This method respects the complex work setting Use all-or-none scheduling for related appointments. If there are no available slots, appointments in the complex work chain aren’t scheduled.

The scheduleExtended method is valid for a chain of two appointments; if the appointment in serviceId has dependencies with more than one other appointment, scheduling results can be different than expected.

This method can be called with only one service appointment at a time, and runs asynchronously. To examine results that this method returns, you can use the streaming API and subscribe to MstCompletedChannel, the channel for the FSL managed package.

If you are using the scheduleExtended method with the appointment booking method, perform a time zone conversion. The results of appointment booking are returned in the time zone specified in the method signature. Convert these values back to UTC.