Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

JasonHoult1981 commented Mar 25, 2021

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

@thoriyas
Copy link

thoriyas commented Mar 31, 2021

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