Calendars Stopped Pulling Into Drafts

I’ve been successfully pulling my calendar events across several calendars with an action (pasted below with calendar names for this posting) that has suddenly stopped working.

I’ve not made any changes to any of the calendars it is pulling from… Nor to the action.

This issue started a week to 10 days before Drafts 54 was released (was not able to post till now.)

Can anyone make suggestions on:

  1. How to troubleshoot - I would not even know where to begin
  2. Make suggestions as to why this stopped working?

Many thanks.

Script from the action:

// Calendar Events to Clipboard - Extract meetings for specified date

// Prompt for date input
let prompt = new Prompt();
prompt.title = "Enter Date for Calendar Events";
prompt.message = "Enter date in YYYYMMDD format (e.g., 20250822)";
prompt.addTextField("dateInput", "Date", "", { placeholder: "20250822" });
prompt.addButton("Get Events");
prompt.addButton("Cancel");

if (!prompt.show() || prompt.buttonPressed === "Cancel") {
    context.cancel("Action cancelled");
}

let inputDate = prompt.fieldValues["dateInput"].trim();

// Validate date format (basic check for 8 digits)
if (!/^\d{8}$/.test(inputDate)) {
    app.displayErrorMessage("Invalid date format. Please use YYYYMMDD (e.g., 20250822)");
    context.cancel("Invalid date format");
}

// Get calendar events for the specified date
let targetDate = new Date(
    parseInt(inputDate.substr(0, 4)), // year
    parseInt(inputDate.substr(4, 2)) - 1, // month (0-based)
    parseInt(inputDate.substr(6, 2)) // day
);

let calendarNames = ["EMO", "MOOFrasca", "Farm2", "jmf@123.com"];
let allEvents = [];

// Get events from each specified calendar
for (let calName of calendarNames) {
    try {
        let cal = Calendar.findOrCreate(calName);
        if (cal) {
            let startOfDay = new Date(targetDate);
            startOfDay.setHours(0, 0, 0, 0);
            
            let endOfDay = new Date(targetDate);
            endOfDay.setHours(23, 59, 59, 999);
            
            let events = cal.events(startOfDay, endOfDay);
            allEvents = allEvents.concat(events);
        }
    } catch (error) {
        console.log(`Could not access calendar: ${calName} - ${error.message}`);
    }
}

// Process calendar events into clipboard format
let clipboardEntries = [];
for (let event of allEvents) {
    if (!event.isAllDay) {
        // Skip EFL Standup meetings (standing meeting)
        if (event.title.toLowerCase().includes("efl standup")) {
            continue;
        }
        
        let startTime = event.startDate;
        let hour = String(startTime.getHours()).padStart(2, '0');
        let minute = String(startTime.getMinutes()).padStart(2, '0');
        let militaryTime = `${hour}:${minute}`;
        
        clipboardEntries.push({
            time: militaryTime,
            timeInMinutes: startTime.getHours() * 60 + startTime.getMinutes(),
            title: event.title,
            line: `${militaryTime} ${event.title}`
        });
    }
}

// Sort entries by time
clipboardEntries.sort((a, b) => a.timeInMinutes - b.timeInMinutes);

// Create clipboard content
let clipboardContent = clipboardEntries.map(entry => entry.line).join('\n');

if (clipboardEntries.length > 0) {
    // Copy to clipboard
    app.setClipboard(clipboardContent);
    
    // Display success message
    app.displayInfoMessage(`${clipboardEntries.length} calendar event(s) copied to clipboard for ${inputDate}`);
    
    // Log the entries
    console.log(`Calendar events for ${inputDate} copied to clipboard:`);
    clipboardEntries.forEach(entry => {
        console.log(entry.line);
    });
    
} else {
    app.displayInfoMessage(`No calendar events found for ${inputDate}`);
    console.log(`No calendar events found for date ${inputDate}`);
}

Are you getting an error of any sort when the action runs? (Look in the action log)

That’s where to start.

Thanks @agiletortoise … I ran the action and here is the result from the action log:

Not sure where to go from here…

This action is neither working on my MacBook Pro nor my iPhone.

Thanks for your help…

I don’t know, honestly. It’s working here…the only thing I changed in the script is the calendar names to match some of mine.

I’d say a permissions problem is likely, but that would usually just be on one device - but try making sure Drafts has calendar access in System Settings > Privacy, and try toggling it off and back on if it does.

I turned off Calendar access under privacy —

Now, 3 of 4 calendar events ARE being pulled into Drafts.

I do have fantastical accessing my calendars - and am having no issues with the 4th calendar.

Seems isolated to Drafts…

And still an issue on both Desktop and iPhone.

Any suggestions?

Nothing has changed in any recent updates to Drafts in this area. It could be an issue with the OS level APIs, I don’t know.

I’d do more troubleshooting around what might be different about those calendars or events that are not appearing. e.g. could this be time zone related? Something related to all-day events vs. not?

Figured it out: the calendar mysteriously disappeared from iOS. Added it back and now all is good again.

1 Like