Salesforce Field Service: Create Batches of Appointments with Service Appointment Generator

Last update: January 31, 2022

Authors: Leigh-Anne Nugent and Christopher Albanese

Watch the Video. Send us Feedback!

Business Requirements 

Customers need to be able to build a solution that supports the following scenarios for teamwork and multi-stage work:

  1. Wanting in day changes to the Crew Member/Job Assignment i.e. a crew member called in sick on Monday and we need to send someone in just for that day
  2. Partial job assignment to a new Crew Member for a single day of the multi-day i.e. tech assigned on Monday but will see the whole week on the mobile app and also doesn’t get alerted or have an Assigned Resource created
  3. When various resources are required throughout the duration of the job i.e. need someone with troubleshooting skills for the first day, then a mechanic the second day, then an electrician the third day (team approach)

This will provide a stop-gap accelerator-style solution that will be an unmanaged package with access to the source code for customers to modify.

General Capabilities and Principles

  • Leverage the knowledge of the dispatcher to generate a collection of Service Appointments (SAs), assigned to designated Service Resources (SRs or techs) by creating Assigned Resource (AR) records. It improves the end-user experience for the creation and maintenance of a large number of SAs which would be administratively burdensome, if not impossible, to do with the out of the box capabilities.  
  • This tool provides an alternative to using the Salesforce Field Service Crew Management and Multiday Work features.  This does not provide an automatic, project-like scheduling tool, it’s intended to enhance multi-resource assignment capabilities.  
  • Generate SAs and Assignments based on the Dispatcher’s direction.
    • Create 2 weeks’ worth of SAs, with the option to include Saturday and/or Sunday, for Gloria and Alan for this Work Order.
  • Generate an ad hoc batch of SAs to staff a night shift for a given period of time.
    • The customer reduced the due date which requires an overnight shift to be added for the job to finish on time.
  • View the SAs for a Work Order and edit them in an easy, spreadsheet-style way.
    • The customer wants the job finished sooner, which means we need to add 2 hours to each SA Duration.
  • Selectively Delete SA and Delete all SAs.
    • The customer called and says we can’t be on-site for a set of days or wanted to cancel the whole job.
  • Move jobs from one resource to another.
    • Fred is out for 3 days so move a set of his appointments to another Service Resource.
  • Push some or all of the jobs N days into the future or to a new date.
    • The customer says we can’t be on-site for a set of days, so shift all appointments to when we can go back on site.

Phase 1  Features

(MVP) As a Scheduler, I know what jobs my resources are working on. I should be able to:

  • Set the Service Appointment Parameters I need to determine the first date on-site, the last date on-site (or in the batch), the Start Time, the Duration on-site. 
  • When I’m scheduling jobs outside of my Timezone, I want to be able to be clear about what Timezone I am creating the Service Appointments for so that I can properly offset the Start Time in the Service Appointment Creation Parameters screen.  
  • I need to be able to select from a list of Service Resources that have a Primary or Secondary Territory Membership record of the Service Territory of the Work Order (or manually selected). 
  • In the Resource selection list, I want to know if the Service Resources have any existing Absences and/or Service Appointments already assigned to them during the date range selected so I can select the Service Resources that have the most availability.  
  • In the Service Appointment Creation Review list, I need the ability to NOT create some Service Appointments for some Service Resources on some dates because they only need to be on-site for some of the days in the batch.
  • I need all created and Assigned Service Appointments to appear on the dispatcher console as soon as they are assigned and I need any updates made in the dispatcher console to reflect in the data table Service Appointment review screen (and vice versa).
  • I need the ability to create and assign additional batches of Service Appointments that may include night shift and/or off-shift coverage to shorten the elapsed duration of the job. 
  • When I create new assignments, I’d like to be guided by the dates of the SAs that have already been created so I know where to create the next batch of SAs (visibility on the summary table).
  • When I create additional assignments, I’d like to be guided by the overall Work Order Start and End Dates so I don’t create SAs outside of this date range (visibility on the summary table).
  • I want the option to create a single batch of Service Appointments for more than 14 days (up to 16 weeks) if I know I only need 1 or 2 resources to assign work and know I will be well below the tool limits of 1000 SAs in the Data Table.
  • I want to be able to review all of the Service Appointments and Assignments across all of the days so I can see everyone who has been assigned.
  • I need to be able to move all or some of the Service Appointments to another start date so I don’t have to manually update each appointment start date/time.
  • I want to be able to edit the Scheduled Stat and/or the Duration of selected Service Appointments and have the Scheduled End recalculate for me so I don’t have to worry about calculating and updating that field myself.
  • I want to mass delete all or selected open assignments if the job gets rescheduled or canceled to simplify the data management of deleting each one manually.
  • I want to reassign all or some of the open assignments if a resource becomes unavailable (team shuffle) to simplify the data management of reassigning each one manually.

End-User Guide

  1. Create SA Screen
    1. Parameter screen
      1. When there aren’t any Service Appointments for the Work Order, you will be presented with the Service Appointment Parameters including the technicians you want to surface.
      2. The Start Time is presented in the Users Salesforce Time Zone. Consider the TimeZone offset if you are creating Service Appointments in a different TimeZone.
    2. Service Resource selection table
      1. This Data Table will show you all the Service Resources a dispatcher can select to assign work to.
      2. Select as many resources you would want to add to the job.
    3. Service Appointment selection table
      1. This Data Table will show you all draft SAs for the entire duration of the job and for each tech.
      2. Select the SAs to keep; you can select all the rows and deselect the ones you don’t want. 
      3. Can sort by Scheduled Start Date or Service Appointment.
      4. Can inline edit the Scheduled Start Time and Duration. 
  2. Edit SA Screen
    1. When there are Service Appointments for the Work Order, you will be presented with two options: Edit SAs or Create SAs.
    2. Edit SAs
      1. This Data Table will show you all Final SAs for the entire duration of the job and for each tech.  Can inline edit the Scheduled Start Time and Duration. 
      2. You will have three new options as well as a Data Table.
        1. Change Service Resource – Use this feature when you have to shift a set of SAs to new Service Resource.
          1. Select the SAs you would like to reassign in the Data Table.
          2. Select the Service Territory and Skills to build the list of Service Resources to select.
          3. Select the Service Resource from the Data Table.
          4. All Assigned Resource records will be updated to the new Service Resource.
        2. Shift Appointment Dates – Use this feature when you have to shift a set of SAs to new start date.
          1. Input the start date and the end date range of the SAs to move.
          2. Input the new date to shift the SAs to.
        3. Delete Service Appointments – Use this feature when you have to delete an ad hoc set of SAs.
          1. Select the SAs you would like to delete in the Data Table.
    3. Create SAs
      1. You will be redirected to the create Service Appointment parameters screen.
  3. Delete All SAs
    1. Use this when you need to delete all of the Service Appointments.

Considerations

  1. Datatable presents date/time in the user’s machine settings, not Salesforce User TimeZone or the Service Territory TimeZone. 
  2. The max number of rows of Service Appointments the Data Table can display is 1000 rows.  Keep this in mind when creating your Service Appointment batches. Its recommended to create batches 2 weeks at a time to keep the numbers down for performance.
  3. Validation rules are caught when you try to save the records (you won’t see them in the table).
  4. Any scheduling conflicts will have to be resolved in the Gantt based on rule violations.
  5. You won’t see the list of Skills each Service Resource has in the table.
  6. If you don’t select any rows in the Service Appointment creation table, you could possibly not create any SAs.
  7. It’s not recommended to mass edit the Date/Time fields in the Data Table Service Appointment.  It will update all the records to be the same date and time; you won’t only just update the date value. 
  8. If you back out of the flow or sit in the flow screen for over 10 minutes, you might have SAs in a Draft status until the Delete Service Appointment Triggered Flow comes in to delete them (but this time frame can be changed in the flow).
  9. If an appointment is shifted and crossed a daylight saving transition period, this will have to be manually adjusted as it is not accounted for in the solution.
  10. The Service Appointment edit table is not filtered by status but can be configured if desired.
  11. Consider the implications when the package is retired if/when this feature is added to the Product long term roadmap
    1. It is recommended to document the configuration in detail to then determine if something would require refactoring or removal.   

Developer Guide

Data Model

Service Appointment Fields

  • MR Service Resource – this is the Service Resource that the Dispatcher has assigned. It is used to create the Assigned Resource record when creating a new Service Appointment.
  • MR Parent Work Order – this is the Work Order that owns the Service Appointment.
  • MR Creation Status – Picklist of Draft, Confirmed, Deleted, This is used to drive the creation process as well as the automatic deletion of Draft SAs that don’t get confirmed or deleted (user just exits the flow with completing)

Work Order Fields

  • MR_Estimated_Calendar_Days__c
  • MR_Hours_Actual__c
  • MR_Hours_Completed__c
  • MR_Hours_Created__c
  • MR_Hours_Scheduled__c
  • MR_Hours_To_Be_Assigned__c
  • MR_Hours_To_Be_Created__c
  • MR_Number_of_Techs_Needed__c
  • MR_Total_Hours_Required__c
  • MR_Trigger_Cleanup__c – Used by the time based workflow to delete Draft SAs
  • MR_Trigger_Date_Time__c – Used by the time based workflow to delete Draft SAs

Service Territory Member Fields

  • MR Resource Name – formula field to display Service Resource Name
  • MR Service Territory – formula field to display Service Territory Name

Automation

Flows

  • MR DT Service Appointment Main (name = Multi Resource Assignment Wizard) – calls Creator, Review and Delete
  • MR DT Service Appointment Creator
  • MR DT Delete Service Appointments – Mass delete all of the SAs for a Work order
  • MR DT Service Appointment Review – Update, Change Techs and Delete selected SAs
  • MR DT Trigger Delete Flow – Time Based flow which deletes Draft SAs that have not been confirmed within 10 minutes (parameter can be changed)
  • MR DT Update sched end time – Record Triggered flow to recalculate SchedEndTime if SchedStartTime and/or Duration change. 

Apex Classes

  • WOSchedulePayload – Class  used to contain the parameters set by the user and pass them to the batch apex job
  • MRDTAssignment – Assigns SAs to their Assigned Resource – called by MR DT Service Appointment Creator
  • MRDTGETSTMs – Returns filtered list of STMs based on Territory and Skills and Start / End Dates
  • MRDTReassignTechs – Called by MR DT Service Appointment Review Flow and used to reassign existing SAs to a new Resource
  • MRDTSchedMultiVisit – called by MR DT Service Appointment Creator and is used to create the SAs initially
  • MRDTDateShift – move selected appointments to a new date
  • MRDTSAValidateUpdate – update any discrepancies between manual updates to SA, like a drag and drop, with the MR_Service_Resource field. return list of SAs to the Review flow along with count of SAs.
  • MRDTGetTimeZoneInfo – returns the timezone offset between the running users timezone and selected service territory’s timezone. This is used by the MR DT Service Appointment Creator flow to generate a warning message to the user if the timezone offset is not 0.

Test Classes

  • WOSchedulePayloadTestClass
  • MRDTAssignmentTestClass
  • MRDTGETSTMsTestClass
  • MRDTReassignTechsTestClass
  • MRDTSchedMultiVisitTestClass
  • MRDTDateShiftTestClass
  • MRDTSAValidateUpdate
  • MRDTGetTimeZoneInfoTestClass

Platform

Permission Sets

  • MR DT Permission Set – grants access to all of the fields and classes above

Other Requirements

  • Prior to use, you must deactivate Service Appointment Validation Rule called: Dont_allow_scheduled_or_dispatched

Installation Steps

  1. Install Base and Screen Base packs
  2. Install Datatable
  3. Install the Service Appointment Generator package
    1. Sandbox Installation Link: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000GV6u2UAD
    2. GitHub Repository: https://github.com/cxalbanese/multiresource.git 
  4. Deactivate Validation Rule on Service Appointment called: Dont_allow_scheduled_or_dispatched
  5. Assign Permission Set to Users who will use this package: MR DT Permission Set
  6. Add flow to work order page: Multi Resource Assignment Wizard

Optional Configuration Steps

  1. Update Flow Screen messaging to suit your business process 
  2. Other fields to display in the Data Tables to suit your business process

Related Requests, that are not related to the SA Generator solution

We heard these other requirements that would improve the end-user experience.  Consider building something yourself to help with these.

  1. As a Scheduler, I want to be able to go to the Dispatcher console and visibly identify the Service Appointments for the Work Order so I don’t get confused with all the jobs on the Gantt. 
  2. As a Scheduler, I want an easy way to clone a Service Appointment from another Service Appointment on the Dispatcher Console so that it is easy to add another appointment for one more day.

Feature Requests

Jobs to be DoneStatusNext Steps
As a Scheduler, I’d like the flexibility to select the Timezone I’d like the Service Appointments to be scheduled in when setting up the initial parameters.  Design note: Data table renders the Date/Time fields in the context of the MACHINE settings.  Also, mass edit doesn’t only update the start time, it updates the date and the times.CapturedReview and determine next step
As a Scheduler, in the draft Service Appointments list, I want to know if that SA has an existing Absence or Service Appointment on that date so I can immediately see the conflicting record for that specific Service Appointment (or use any ensuing Gantt violations as guard rails for the dispatcher to use to tweak the schedule for a given Work Order).CapturedReview and determine next step
As a Scheduler, I want to define the Skills required at the Work Order and have the Match Skills rule consider that the combined Skills of the people I have Assigned to the WO will fulfill the Work Order Skill Requirements.CapturedReview and determine next step
As an Admin, I want to be able to modify the screen flow so that I can insert another Data Table displaying the individual dates with start times and durations before seeing the Resources to select so that the rough schedule can be created before selecting the resources that will be assigned.CapturedReview and determine next step
As a Scheduler, when I am deleting a set of SAs, I’d like an additional confirmation screen so that I don’t accidentally delete records.CapturedReview and determine next step
As a Scheduler, I want the option to let the scheduling engine select the resource based on a defined Role required for each SA (extended match).CapturedReview and determine next step
As a Scheduler, I’d like to have a job template that could create WOLIs with the required skills (sub-work types) that can be applied for each Task.CapturedReview and determine next step
As a Tech using the app, I need to see who else is going to be on-site on the same day so that I can see if I can carpool with someone.CapturedReview and determine next step
As a Tech using the app, I need to see the tool that was assigned to me so that I can bring the right tool on site.CapturedReview and determine next step
As a Site Supervisor using the app, I need to see all of the people who are staffed on the job each day so that I know who to expect and when (they are ok seeing the data table in the App).CapturedReview and determine next step
As an Admin, I’d like to have access to Setup Controls to help identify which automation to enable.

– Status Filters for SA edits
– Align Earliest Start and Due date if the Scheduled Start/Scheduled End is updated
– Set how long the Draft SAs stay in Draft
– Error Message and Screen Message Templates
CapturedReview and determine next step
As an Admin, I want to be able to bring the component into Custom Gantt Actions to Create SAs, Edit SAs (make the component a VF Custom Gantt Action)CapturedReview and determine next step