• Instructions to Ask a Question

    For any assistance, please click the "Ask a Question" button and select the Pabbly product for which you require support.

    We offer seven comprehensive applications designed to help you efficiently manage and grow your business:

    Our support team endeavors to respond within 24 business hours (Monday to Friday, 10:00 AM to 6:00 PM IST). We appreciate your understanding and patience.

    🚀 Exclusive Lifetime Offers 🚀

    We invite you to take advantage of our special one-time payment plans, providing lifetime access to select applications:

    • 🔥 Pabbly Connect — Lifetime Access for $249View Offer
    • 🔥 Pabbly Subscription Billing — Lifetime Access for $249View Offer
    • 🔥 Pabbly Chatflow — Lifetime Access for $249View Offer

    Make a one-time investment and enjoy the advantages of robust business management tools for years to come.

Trigger every Wednesday only in even calendar weeks (for Active Campaign)

Status
Not open for further replies.
I have a slightly more complex requirement. I want to send an automation email in Active Campaign that sends every Wednesday, but only in even calendar weeks.
Unfortunately, this is not possible with Active Campaign itself. Hence the question, can I somehow create a trigger with Pabbly Connect that takes the calendar weeks into account and triggers automation in Active Campaign? Unfortunately, I couldn't find any corresponding modules myself and hope that I may have simply overlooked something.

I would be very happy about some support.
Thank you in advance!
 

ArshilAhmad

Moderator
Staff member
Hi @ollidoetsch,

You can add these steps to your workflow as a workaround. Even though this workflow will trigger every Wednesday, the action step after the Filter will be executed only if Wednesday falls on an even week.


JavaScript:
function getWeekParity(inputDate) {
    // Convert input string to Date object
    const dateObject = new Date(inputDate);

    // Calculate the ISO week number
    const isoWeekNumber = getISOWeek(dateObject);

    // Determine if the week is odd or even
    const weekParity = isoWeekNumber % 2 === 0 ? "Even" : "Odd";

    return weekParity;
}

// Function to calculate ISO week number
function getISOWeek(date) {
    const startOfYear = new Date(date.getFullYear(), 0, 1);
    const diff = date - startOfYear;
    const oneWeek = 604800000; // milliseconds in a week
    return Math.ceil(diff / oneWeek);
}

// Example usage with a hardcoded date
const inputDate = "2024-01-24"; // Specify the date directly
const parityResult = getWeekParity(inputDate);
console.log(`The week for ${inputDate} is ${parityResult}.`);
 
Status
Not open for further replies.
Top