Google カレンダー: 予定削除

Google Calendar: Delete Event

この工程は、Google カレンダーの予定を削除します。

Auto Step icon
Basic Configs
工程名
メモ
Configs for this Auto Step
conf_User
C1: Google カレンダー に接続するユーザ(要アプリ管理権限) *
conf_CalendarId
C2: Calendar ID (空白の場合、プライマリのカレンダー)
conf_EventId
C3: 予定 ID *

Notes

  • C1 のユーザは、[アカウント設定]>[Google 連携]にて、Google カレンダーと連携済みである必要があります
    • ワークフロー基盤にて、Google 連携設定([システム設定]>[Google 連携])が必要です(要[システム管理権限])
  • カレンダー ID は次のページを参照します。[カレンダー設定](Calendar Settings)>[カレンダーのアドレス](Calendar Address)
  • 予定 ID はカレンダー画面からは取得できません。開始: Google カレンダー: 予定開始時などで取得したものを使用してください。

Capture

See also

Script (click to open)
  • 次のスクリプトが記述されている XML ファイルをダウンロードできます
    • google-calendar-event-delete.xml (C) Questetra, Inc. (MIT License)
    • Professional のワークフロー基盤では、ファイル内容を改変しオリジナルのアドオン自動工程として活用できます

main();
function main() {
    //// == 工程コンフィグの参照 / Config Retrieving ==
    const quser = configs.getObject("conf_User");
    if (quser === null) {
        throw `User not found.`;
    }
    let calendarId = configs.get("conf_CalendarId");
    if (calendarId === "" || calendarId === null) {
        calendarId = "primary";
    }
    const eventId = engine.findData(configs.getObject("conf_EventId"));
    if (eventId === "" || eventId === null) {
        throw "Event ID isn't set.";
    }

    //// == 演算 / Calculating ==
    if (calendarId.search(/^[\w\-_.!*'@]+$/) === -1) {
        throw "Invalid Calendar ID.";
    }
    deleteEvent(quser, calendarId, eventId);
}
/**
 * Google カレンダーの予定を削除する
 * @param {QuserView} quser ユーザー
 * @param {String} calendarId カレンダーID
 * @param {String} eventId 予定ID
 */
function deleteEvent(quser, calendarId, eventId) {
    const uri = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/${eventId}`;

    const response = httpClient.begin()
        .googleOAuth2(quser, "Calendar")
        .delete(uri);

    const status = response.getStatusCode();
    const responseStr = response.getResponseAsString();
    engine.log(`Event ID: ${eventId}`);

    if (status >= 300) {
        engine.log(responseStr);
        throw `Failed to delete. status:${status}`;
    }

    engine.log("Succeeded to delete.");
}
%d