Skip to content

ScheduledMaintenanceService Class

Ethan Dunzer edited this page May 22, 2024 · 2 revisions

Overview

The ScheduledMaintenanceService class is designed to manage and retrieve scheduled maintenance records within a Salesforce application. This service provides methods to fetch active scheduled maintenances for a specified application context and to retrieve an application ID based on its developer name.

Methods

getActiveScheduledMaintenances

This method retrieves active scheduled maintenances applicable to the specified application context.

Signature:

  • @AuraEnabled(cacheable=false)
  • public static List<Scheduled_Maintenance__c> getActiveScheduledMaintenances(String appContext)

Parameters:

  • appContext: A String representing the application context for which the scheduled maintenances are to be retrieved. If no context is provided, it defaults to the 'System' context.

Returns:

  • A list of active Scheduled_Maintenance__c records.

Details:

  • Captures the current date and time.
  • Initializes a filter list with 'System' as the default filter.
  • Adds the provided app context to the filter list if it is not null or empty.
  • Constructs a SOQL query string to fetch active scheduled maintenance records that fall within the current date and time and match the specified app contexts.
  • Executes the query and returns the list of scheduled maintenance records.

Example Usage: This method can be used to fetch active maintenance records for a specific application context by passing the context name as a parameter.

getAppIdByDeveloperName

This method retrieves the application ID based on the developer name specified.

Signature:

  • @AuraEnabled(cacheable=true)
  • public static String getAppIdByDeveloperName(String developerName)

Parameters:

  • developerName: A String representing the developer name of the application.

Returns:

  • The durable ID of the application if found; otherwise, null.

Details:

  • Queries the AppDefinition object to find an application by its developer name, limited to one result.
  • Returns the durable ID of the found application.
  • Returns null if no matching application is found.

Example Usage: This method can be used to fetch the durable ID of an application by providing the developer name of the application.