1

I'm trying to use the getABSlots method of the AppointmentBookingService class, after setting up the "complex work" of service appointments in our field service settings.

This is how our relationship looks like:

  • Work Order
  • 2 Work Order Line Items with the work type that specifies the duration of each service
    • 2 service appointments, one related to each Work Order Line Item
    • 1 AD (Appointment Dependency between SA's)

Here is how the implementation looks like programmatically:

ServiceAppointment sa = [SELECT Id, AppointmentNumber, EarliestStartTime, DueDate FROM ServiceAppointment 
                            WHERE Id='08p1g00001R2Dy7AAF'];
Id schedulingPolicyId = [SELECT Id FROM FSL__Scheduling_Policy__c 
                            WHERE Name='Customer first' LIMIT 1].Id;
OperatingHours oh = [SELECT id FROM OperatingHours 
                            WHERE name='Gold Appointments Calendar' LIMIT 1];
Timezone tz = UserInfo.getTimeZone();

FSL.ABSlotsResponse slotList = FSL.AppointmentBookingService.getABSlots(sa.Id,schedulingPolicyId, oh, tz,'SORT_BY_DATE',false);
System.debug('Returned ' + slotList);

However, the result for the Slots object is always empty. The API documentation of the getABSlots method on https://developer.salesforce.com/docs/atlas.en-us.field_service_dev.meta/field_service_dev/apex_class_FSL_AppointmentBookingService.htm says:

This method is asynchronous. To examine the results that this method returns, you can use the streaming API and subscribe to MstCompletedChannel, the channel for the Field Service managed package.

Would anyone be able to clarify why would we need streaming API to listen to the available slots of this API call? And if truly needed, how to subscribe to this channel?

I know is hard to identify why the slots might not be retrieved by looking at the code, but any guidance here will be great. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.