Check Salesforce Field Service enabled using Apex

Check Salesforce Field Service enabled using Apex

When Salesforce Field Service is enabled and configured, specific objects and fields become available or are populated.

WorkOrder object: WorkOrder object or entity is available only when Salesforce Field Service feature is enabled.

Use the following sample Apex code to find or check whether the Salesforce Field Service feature is enabled or not using Salesforce Apex.

Sample Apex Code:

Map < String, Schema.SObjectType > globalDescription = Schema.getGlobalDescribe();

if ( globalDescription.containsKey( 'WorkOrder' ) ) {
    
    System.debug( 'Field Service enabled' );
    
} else {
    
    System.debug( 'Field Service disabled' );
    
}

Leave a Reply