function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Artsiom KazachinskiyArtsiom Kazachinskiy 

Work with Field Service in Apex

Good day. We use a field service in our salesforce org in conjunction with a lightning site and apex backend.
In salesforce docs, we have found methods for scheduling service appointments - getSlots(serviceID, policyId, operatingHoursId, tz, exactAppointment);
Can you please give a recommendation on how to assign service resources through the apex. At the moment, we have implemented a manual insert for record the object assigned resources.
Forum TeamForum Team
Hi Artsiom,

I'm assuming you have the slots and other required info. To achieve assignment through apex please follow the steps below:
1. Query the first available(IsActive = true) ServiceResource record depending upon ResourceType
2. Create an AssignedResource record with required information and set the ServiceResourceId from the record in step 1.

I hope that answers your query.