Last active
August 1, 2018 09:45
-
-
Save SalesforceBobLightning/ff6aeb442ec568df8a27d835c768fb53 to your computer and use it in GitHub Desktop.
Write to System.Debug from Salesforce Process Builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SystemDebugAction { | |
@InvocableMethod( | |
label='System Debug' | |
) | |
public static void logDebugMessages(List<Request> requests) { | |
for(Request request : requests){ | |
logDebugMessage(request); | |
} | |
} | |
public static void logDebugMessage(Request request) { | |
if (String.isNotBlank(request.loggingLevel)){ | |
System.debug(getLoggingLevel(request), request.debugMessage); | |
} else { | |
System.debug(request.debugMessage); | |
} | |
} | |
private static LoggingLevel getLoggingLevel(Request request){ | |
switch on request.loggingLevel { | |
when 'NONE' { | |
return LoggingLevel.NONE; | |
} | |
when 'ERROR' { | |
return LoggingLevel.ERROR; | |
} | |
when 'WARN' { | |
return LoggingLevel.WARN; | |
} | |
when 'INFO' { | |
return LoggingLevel.INFO; | |
} | |
when 'DEBUG' { | |
return LoggingLevel.DEBUG; | |
} | |
when 'FINE' { | |
return LoggingLevel.FINE; | |
} | |
when 'FINER' { | |
return LoggingLevel.FINER; | |
} | |
when 'FINEST' { | |
return LoggingLevel.FINEST; | |
} | |
when else { | |
return LoggingLevel.FINEST; | |
} | |
} | |
} | |
public class Request { | |
@InvocableVariable( | |
label = 'Debug Message' | |
required=true | |
) | |
public String debugMessage; | |
@InvocableVariable( | |
label = 'Logging Level' | |
required=false | |
) | |
public String loggingLevel; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment