Field Service Lightning Developer Guide
Summer '26 (API version 67.0)
Spring '26 (API version 66.0)
Winter '26 (API version 65.0)
Summer '25 (API version 64.0)
Spring '25 (API version 63.0)
Winter '25 (API version 62.0)
Summer '24 (API version 61.0)
Spring '24 (API version 60.0)
Winter '24 (API version 59.0)
Summer '23 (API version 58.0)
Spring '23 (API version 57.0)
Winter '23 (API version 56.0)
Summer '22 (API version 55.0)
Spring '22 (API version 54.0)
Winter '22 (API version 53.0)
Summer '21 (API version 52.0)
Spring '21 (API version 51.0)
Winter '21 (API version 50.0)
Summer '20 (API version 49.0)
Spring '20 (API version 48.0)
Winter '20 (API version 47.0)
Summer '19 (API version 46.0)
Spring '19 (API version 45.0)
Winter '19 (API version 44.0)
Summer '18 (API version 43.0)
Spring '18 (API version 42.0)
Get Ready to Develop with Field Service Lightning
Generate Work Orders on Maintenance Plans with Apex
Create a Service Report with Apex
Apex Trigger: Auto-Close Cases with Closed Work Orders
Apex Trigger: Prevent Closure of Work Orders with Open Line Items
Apex Trigger: Send Email when Service Report is Created
Apex Class: Create a Work Order with a Work Order Line Item
Code Samples: Dispatcher Console Custom Actions
Newer Version Available
Field Service Lightning Code Samples
Use these code samples to get started working programmatically with Field Service
Lightning features.
-
Generate Work Orders on Maintenance Plans with Apex
The Generate Work Orders action on maintenance plans can also be called using Apex code. The following code sample creates work order records by making an Apex callout to the generateWorkOrder action REST API resource. -
Create a Service Report with Apex
The Create Service Report action on work orders, work order line items, and service appointments can also be called using Apex code. The following code sample creates a service report with two signatures by making an Apex callout to the createServiceReport action REST API resource. -
Apex Trigger: Auto-Close Cases with Closed Work Orders
The following trigger automatically closes cases when a work order linked to the case is marked Closed. It saves support agents from having to manually close a case after the related work is complete. -
Apex Trigger: Prevent Closure of Work Orders with Open Line Items
The following trigger prevents users from closing a work order unless all its line items have been closed. It’s a good way to ensure that all scheduled tasks are completed. The accompanying unit test scans your code for issues. -
Apex Trigger: Send Email when Service Report is Created
The following trigger sends an email to a specified email address when a service report is created in your org. For example, you may want your payroll department to be notified whenever a service report is created. -
Apex Class: Create a Work Order with a Work Order Line Item
Apex classes reduce the size of your triggers and make it easier to reuse and maintain Apex code. This class, which you can reference in triggers, creates a work order with one line item. -
Code Samples: Dispatcher Console Custom Actions
Learn how to configure Apex classes or Visualforce pages that you want to link to a custom action in the dispatcher console.