Created
August 21, 2023 12:50
-
-
Save amitastreait/df93a265f4fe2a2b1e9830a873950626 to your computer and use it in GitHub Desktop.
Invocable Apex
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 DateClassUtility { | |
@InvocableMethod(label='Date Operations' | |
description='Operations related to date class' | |
category='Date Utils' | |
iconName='slds:standard:date_time' | |
) | |
// iconName - <slds:category:name> // see | |
// iconName - <resource:namespace:resourceId> // managed packages | |
public static List<Date> dateUtils(List<InputWrapper> inputs){ | |
// Date, Operation (addDays), NumberOfDays | |
Date outputDate; | |
if(inputs != null && inputs.size()>0){ | |
InputWrapper input = inputs.get(0); | |
if(input.operationType == 'addDays'){ | |
outputDate = input.inputDate.addDays(input.numberOfDays); | |
}else if(input.operationType == 'addMonths'){ | |
outputDate = input.inputDate.addMonths(input.numberOfMonths); | |
} | |
} | |
return new List<Date>{outputDate}; | |
} | |
public class InputWrapper{ | |
@InvocableVariable(label='Provide Date on which you want to perform operation' | |
required=true description='Provide Date on which you want to perform operation') | |
public Date inputDate; | |
@InvocableVariable(label='Provide the Operation that you want to perform' required=true | |
description='The valid operation types are addDays, addMonths, addYears') | |
public String operationType; | |
@InvocableVariable(label='Number of Months' required=false description='Number of Months for the operation') | |
public Integer numberOfMonths; | |
@InvocableVariable(label='Number of days' required=false description='Number of days for the operation') | |
public Integer numberOfDays; | |
} | |
} |
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 StringUtils { | |
@InvocableMethod(label='Convert String to Array & Vice Versa' | |
description='Convert String to Array & Vice Versa' | |
category='PantherSchools' | |
iconName='slds:custom:custom57' | |
) | |
public static void stringUtils(List<InputWrapper> inputs){ //List<Object> | |
if(inputs != null && inputs.size()>0){ | |
InputWrapper input = inputs.get(0); | |
String colors = 'Red,Blue,Yellow'; | |
List<String> colorsList = colors.split(','); | |
// join | |
String joinedString = String.join(colorsList, ':'); | |
} | |
} | |
public class InputWrapper{ | |
@InvocableVariable(label='Provide the String to Convert into Array' | |
description='Provide the String to Convert into Array') | |
public String inputString; | |
@InvocableVariable(label='Provide the List to Convert into String' | |
description='Provide the List to Convert into String') | |
public List<String> inputList; | |
@InvocableVariable(label='Separator to convert String to Array & Vice Versa' | |
description='Separator to convert String to Array & Vice Versa') | |
public String separator; | |
@InvocableVariable(label='Provide the Operation that you want to perform' required=true | |
description='The valid operation types are convertString, convertArray') | |
public String operationType; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment