• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $249 (🏆Lifetime Access) - View offer

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