Last active
March 31, 2021 11:07
-
-
Save cchrisv/78830faa456d457c8cd1ce875e03acf7 to your computer and use it in GitHub Desktop.
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
global class CalculateNextBusinessDate { | |
global class request | |
{ | |
@InvocableVariable (label='Start Date' required = true) | |
global DateTime givenDateTime; | |
@InvocableVariable (label='Business Hours Id' required = true) | |
global String businessHoursId; | |
} | |
global class response | |
{ | |
@InvocableVariable (label='Next Business Date') | |
global DateTime nextAvailableBusinessDate; | |
} | |
@InvocableMethod(label='Professor Flow | Calculate next Business Date' description='Starting from the specified target date, returns the next date when business hours are open. If the specified target date falls within business hours, this target date is returned.') | |
global static List<response> getNextBusinessDate (List<request> inputParams) | |
{ | |
List<response> responseList = new List<response>(); | |
DateTime nextDate; | |
if(inputParams != null && inputParams.size()> 0) | |
{ | |
for(request pf : inputParams){ | |
nextDate = BusinessHours.nextStartDate(pf.businessHoursId, pf.givenDateTime); | |
response rs = new response(); | |
rs.nextAvailableBusinessDate = nextDate; | |
responseList.add(rs); | |
} | |
} | |
return responseList; | |
} | |
} |
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
global class CalculateNextBusinessDate { | |
global class request | |
{ | |
@InvocableVariable (label='Start Date' required = true) | |
global DateTime givenDateTime; | |
@InvocableVariable (label='Business Hours Id' required = true) | |
global String businessHoursId; | |
} | |
global class response | |
{ | |
@InvocableVariable (label='Next Business Date') | |
global DateTime nextAvailableBusinessDate; | |
} | |
@InvocableMethod(label='Professor Flow | Calculate next Business Date' description='Starting from the specified target date, returns the next date when business hours are open. If the specified target date falls within business hours, this target date is returned.') | |
global static List<response> getNextBusinessDate (List<request> inputParams) | |
{ | |
List<response> responseList = new List<response>(); | |
DateTime nextDate; | |
if(inputParams != null && inputParams.size()> 0) | |
{ | |
for(request pf : inputParams){ | |
nextDate = BusinessHours.nextStartDate(pf.businessHoursId, pf.givenDateTime); | |
response rs = new response(); | |
rs.nextAvailableBusinessDate = nextDate; | |
responseList.add(rs); | |
} | |
} | |
return responseList; | |
} | |
} |
If the Start Date is within the given business hours, the Start Date is returned instead of the next business day date.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! - The Test Class is the same as the main class. Can you update for the real test class?