Skip to content

Instantly share code, notes, and snippets.

@cchrisv
Last active March 31, 2021 11:07
Show Gist options
  • Save cchrisv/78830faa456d457c8cd1ce875e03acf7 to your computer and use it in GitHub Desktop.
Save cchrisv/78830faa456d457c8cd1ce875e03acf7 to your computer and use it in GitHub Desktop.
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;
}
}
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;
}
}
@JasonHoult1981
Copy link

Hi! - The Test Class is the same as the main class. Can you update for the real test class?

@thoriyas
Copy link

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