Created
November 7, 2023 21:20
-
-
Save westc/f302f6ea655277f554353487a3b8b95f to your computer and use it in GitHub Desktop.
Utility functions that can be called in Salesforce Apex flows.
This file contains hidden or 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 FlowUtils { | |
@InvocableMethod(label='Format Date/Time') | |
public static String[] format(FormatInput[] inputs) { | |
String[] outputs = new String[0]; | |
for (FormatInput input : inputs) { | |
outputs.add(input.dt.format(input.format, input.tz)); | |
} | |
return outputs; | |
} | |
public class FormatInput { | |
@InvocableVariable( | |
label='DateTime' | |
description='DateTime to format.' | |
required=true | |
) | |
public DateTime dt; | |
@InvocableVariable( | |
label='Format' | |
description='How to format the DateTime. Format details can be found at http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html.' | |
required=true | |
) | |
public String format; | |
@InvocableVariable( | |
label='Time Zone' | |
description='The time zone used to format the DateTime (eg. "America/New_York").' | |
required=true | |
) | |
public String tz; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment