Skip to main content
Version: Next

apex utils

This index lists utility classes and modules for discoverability and code suggestion enhancement.


Logger

Path: force-app/main/utils/classes/Logger.cls

  • finalizeLogging(): Persists all accumulated logs. (static)
  • debug(String output): Logs a debug message at INFO level. (static)
  • debug(LoggingLevel logLevel, String output): Logs a debug message at the specified log level. (static)
  • createExceptionLog(String applicationContext, String methodContext, Exception systemException): Logs an exception with context. (static)
  • createStandardLog(String applicationContext, String methodContext, String message): Logs a standard info message. (static)
  • createStandardLog(String applicationContext, String methodContext, String message, LogContext.LogType logType): Logs a standard message with a specific log type. (static)
  • createHttpLog(String applicationContext, String methodContext, HttpRequest request, HttpResponse response): Logs an HTTP request/response. (static)
  • createHttpLog(String applicationContext, String methodContext, HttpRequest request, HttpResponse response, LogContext.LogType logType): Logs an HTTP request/response with a specific log type. (static)

RemoteSiteUtil

Path: force-app/main/utils/classes/RemoteSiteUtil.cls

  • createRemoteSite(CreateRemoteSiteRequest crssr): Creates a remote site setting using the SOAP MDAPI. (static)
  • remoteSiteSettingRequest_SOAP(CreateRemoteSiteRequest crssr): Returns the SOAP XML for a remote site setting request. (static)

ToolingApiUtil

Path: force-app/main/utils/classes/ToolingApiUtil.cls

  • submitToolingApiRequest(String pathExtension, String method): Submits a Tooling API request with the given method. (static)
  • submitToolingApiRequest(String pathExtension, String jsonBody, String method): Submits a Tooling API request with a JSON body and method. (static)

GenericFormEncoder

Path: force-app/main/utils/classes/GenericFormEncoder.cls

  • convertToXFormUrlEncoded(String requestJSON): Converts a serialized Apex class to x-www-form-urlencoded. (static)

FlexQueueUtil

Path: force-app/main/utils/classes/FlexQueueUtil.cls

  • jobIsRunning(String jobName): Checks if a job with the given name is running. (static)
  • moveJobToFront(Id jobId): Moves a job to the front of the Flex Queue. (static)
  • asyncJobDetails(Id asyncJobId): Returns details for an async job. (static)

MockSObjectBuilder

Path: force-app/main/utils/classes/MockSObjectBuilder.cls

  • setId(): Sets a random Id for the mock SObject.
  • setField(String fieldName, Object value): Sets a field value for the mock SObject.
  • setParent(String parentRelationship, SObject parent): Sets a parent SObject for the mock.
  • build(): Builds and returns the mock SObject.

BusinessHoursUtil

Path: force-app/main/utils/classes/BusinessHoursUtil.cls

  • withinBusinessHours(): Returns true if the current time is within the configured business hours, or false if not. Returns null if no business hours are configured. (static)

StringMasker

Path: force-app/main/utils/classes/StringMasker.cls

  • maskString(String input, Integer maskPercentage, String maskChar): Masks a percentage of the input string with a specified character, leaving the remainder unmasked. (static)

TestFactory

Path: force-app/main/utils/classes/TestFactory.cls

  • createSObject(SObject sObj, String defaultClassName): Creates an SObject with default field values applied from a specified defaults class. (static)
  • createSObject(SObject sObj, String defaultClassName, Boolean doInsert): Creates an SObject with default field values applied from a specified defaults class, with the option to insert it into the database. (static)
  • createSObjectList(SObject sObj, Integer numberOfObjects, String defaultClassName, Boolean doInsert): Creates a list of SObjects with default field values applied from a specified defaults class, with the option to insert them into the database. (static)
  • createSObjectList(SObject sObj, Integer numberOfObjects, String defaultClassName): Creates a list of SObjects with default field values applied from a specified defaults class. (static)