FSL Schedule Service Appointments Anonymously

FSL Schedule Service Appointments With Anonymously Code

The Below code snippet help you to leverage the Appointment Booking and Scheduling Service APIs in the Field Service Lightning Managed Package,where you can programmatically set Arrival Windows and then call the Scheduling Service to get SA scheduled.


1. Firs you need to gather SA, Operating Hours , User time Zone, Scheduling policy 
2. Update below queries to match your org data
3. Pass right parameters to make API call '
FSL.AppointmentBookingService.GetSlots(sa.Id, schedulingPolicyId, oh, tz, sortResults, false);'
4. Once you get the slots , as a next step you need update Arrival Window
5. Then pass parameters to 'FSL.ScheduleService.schedule(schedulingPolicyId,sa.Id);' to schedule this.
6. Below sample is bulkified code , you can use for large set of SA's

Step-1 : To update Arrival Window
**************************

/*=================== CODE To Get Slots Starts ====================*/


/*=================== CODE To Get Slots End ====================*/

/*============== CODE To Update Arrival Window Start ===============*/
 
            sa.ArrivalWindowStartTime = slots[0].Interval.Start;
            sa.ArrivalWindowEndTime = slots[0].Interval.Finish;
            sa.description = 'Passing Via Anonymous Code';
        }

        update
ServiceA;

/*============== CODE To Update Arrival Window End ================*/

Step-2 : To Schedule Appointments
***************************

Post a Comment

1 Comments

Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)