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?
Views
Replies
Total Likes
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; } }
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
@SanmathiKumar Refer to this post for help with this ask.
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!
Views
Replies
Total Likes
@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.
Views
Replies
Total Likes
@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.
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/...
openholidaysapi swagger link: https://openholidaysapi.org/swagger/index.html
API edd point: https://openholidaysapi.org/PublicHolidaysByDate?languageIsoCode=US&date=”Currentdate”
Views
Likes
Replies