Implementing Custom Wait for Non-Weekend and Non-Holiday Dates in AJO | Community
Skip to main content
Level 2
September 10, 2024
Solved

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

  • September 10, 2024
  • 4 replies
  • 1547 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Anuhya-Y

@sanmathikumar 

 Try using a custom action to fetch openholidaysapi. This API can be used to check whether the current date is a holiday based on the country.

Custom action: https://experienceleague.adobe.com/en/docs/journey-optimizer/using/configuration/configure-journeys/action-journeys/about-custom-action-configuration

openholidaysapi  swagger link: https://openholidaysapi.org/swagger/index.html

API edd point: https://openholidaysapi.org/PublicHolidaysByDate?languageIsoCode=US&date=”Currentdate” 

4 replies

harikrishnadevanabowina
Level 4
September 13, 2024

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;
    }
}
Level 2
September 19, 2024

@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.

SatheeskannaK
Community Advisor
Community Advisor
September 13, 2024

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

Thanks, Sathees
Sukrity_Wadhwa
Community Manager
Community Manager
October 18, 2024

Hi @sanmathikumar,

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!

Sukrity Wadhwa
Level 2
October 21, 2024

Hi @sukrity_wadhwa 

 

@satheeskannak's suggestion is one possibility, but I am looking for an expression that doesn't rely on hardcoded holiday dates. Using hardcoded dates would require yearly updates, which isn't ideal. I'm seeking a solution where the holiday dates are automatically fetched through field or something and validated in the condition. 

Alternatively, could this be done through a lookup schema? However, the challenge I'm facing with using a lookup schema is that it isn’t accessible in the data source. Could you please suggest any ideas or alternatives for this use case?

 

Thanks,

Sanmathi.

SatheeskannaK
Community Advisor
Community Advisor
October 22, 2024

@sanmathikumar Lookup tables are only supported on events at this point. Currently events lookup schema is available to use in the journeys (conditions, custom actions, etc.) and message personalization. You can open a ticket with Adobe support and ask to submit an enhancement request by providing the use case details.

Thanks, Sathees
Anuhya-Y
Community Advisor
Anuhya-YCommunity AdvisorAccepted solution
Community Advisor
October 22, 2024

@sanmathikumar 

 Try using a custom action to fetch openholidaysapi. This API can be used to check whether the current date is a holiday based on the country.

Custom action: https://experienceleague.adobe.com/en/docs/journey-optimizer/using/configuration/configure-journeys/action-journeys/about-custom-action-configuration

openholidaysapi  swagger link: https://openholidaysapi.org/swagger/index.html

API edd point: https://openholidaysapi.org/PublicHolidaysByDate?languageIsoCode=US&date=”Currentdate”