Expand my Community achievements bar.

Implementing Custom Wait for Non-Weekend and Non-Holiday Dates in AJO

Avatar

Level 2

Hi,

 

I want to implement a use case using a custom wait or condition in AJO where the current date should return the day of the week, ensuring that the date is neither a weekend nor a public holiday. If the date falls on either a weekend or a public holiday, the profile should wait until the next valid day.

 

Please guide me on how to implement this using the advanced expression editor in AJO?

3 Replies

Avatar

Level 4

Hi @SanmathiKumar 

 

Create a custom activity with name - Wait for Non-Weekend and Non-Holiday

 

and try the following JavaScript

function execute(context) {
    // Get the current date
    var currentDate = new Date();

    // Define weekends and holidays
    var weekends = [0, 6]; // 0 for Sunday, 6 for Saturday
    var holidays = [
        // Add your holiday dates here (e.g., Christmas, New Year's)
        new Date(2024, 11, 25),
        new Date(2025, 0, 1)
    ];

    // Check if the current date is a weekend or holiday
    if (weekends.includes(currentDate.getDay()) || holidays.includes(currentDate)) {
        // If it is, set the wait time to 1 day (or adjust as needed)
        context.waitTime = 86400000; // 1 day in milliseconds
    } else {
        // If it's not, set the wait time to 0 (no wait)
        context.waitTime = 0;
    }
}

@harikrishnadevanabowina

I believe the Advanced Expression Editor or custom activities in AJO do not support the use of JavaScript. From my understanding, AJO is more focused on using expressions and functions within the platform itself, rather than allowing custom JavaScript code.

If there are any workarounds or if it is possible to incorporate JavaScript in some capacity within AJO, I would appreciate further clarification.

Avatar

Community Advisor

@SanmathiKumar Refer to this post for help with this ask.

Thanks, Sathees