Action

Event

Posted by jack1002020, Last update about 4 years ago
  1. Choose your calendar
  2. Choose your start date/time and end date/time
  3. Action will save your topic as event name and your body as note Enjoy~

Steps

  • script

    let calendars = Calendar.getAllCalendars();
    let calendarNames = calendars.map(x => x.title);
    
    let p = Prompt.create();
    p.title = "Calendar";
    p.message = "Select calendar and date range";
    
    p.addSelect("calendar", "Calendar", calendarNames, [], false);
    
    p.addDatePicker("start","Start date", new Date(), {"mode":"dateAndTime"});
    p.addDatePicker("end","End date", new Date(), {"mode":"dateAndTime"});
    p.addButton("Import");
    
    if (p.show()) {
    	let selected = p.fieldValues["calendar"];
    	let ix = calendarNames.findIndex(x => x == selected);
    	let cal = calendars[ix];
    	let start = p.fieldValues["start"];
    	let end = p.fieldValues["end"];
    	if (cal) {
    		var event = cal.createEvent();
    		event.title = draft.displayTitle;
    		event.notes = draft.body;
    		event.startDate = p.fieldValues["start"];
    		event.endDate = p.fieldValues["end"];
    		event.isAllDay = false;
    			if (!event.update()) {
      console.log(event.lastError);
    		}
    	}
    }
    else {
    	context.cancel();
    }

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.