Skip to content

Instantly share code, notes, and snippets.

@westc
Created November 7, 2023 21:20
Show Gist options
  • Save westc/f302f6ea655277f554353487a3b8b95f to your computer and use it in GitHub Desktop.
Save westc/f302f6ea655277f554353487a3b8b95f to your computer and use it in GitHub Desktop.
Utility functions that can be called in Salesforce Apex flows.
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