Outlook Calendar Event Attendees Add
Add attendees to an event in the Outlook Calendar. Specify the target by event ID. Specify attendees by email address. The link URL can be acquired.
Configs for this Auto Step
- conf_OAuth2
- A: OAuth 2.0 Setting *
- conf_eventId
- B: Event Id *#{EL}
- conf_attendees
- C: Attendees email list for Add (comma separated) *
- conf_attendeesOptional
- D: Optional Attendees email list for Add (comma separated)
- conf_eventUrl
- E: Event URL (update)
- conf_log
- X: Access Log (update)
Script (click to open)
// Add Outlook Calendar Event Attendees via Microsoft Graph API v1.0 (ver. 202209)
// (c) 2023, Questetra, Inc. (the MIT License)
//// == 工程コンフィグの参照 / Config Retrieving ==
const oauth2 = configs.get( "conf_OAuth2" ) + "";
const eventId = configs.get( "conf_eventId" ) + "";
const attendeesList = engine.findDataByNumber( configs.get( "conf_attendees" ) ) + "";
let attendeesOptionalList;
const dataId_attendeesOptionalList = configs.get( "conf_attendeesOptional" );
if ( dataId_attendeesOptionalList ) {
attendeesOptionalList = engine.findDataByNumber( dataId_attendeesOptionalList ) + "";
}
const dataId_eventUrl = configs.get( "conf_eventUrl" );
const dataId_log = configs.get( "conf_log" );
//// == 演算 / Calculating ==
if( eventId == "" ){
throw `Event ID none.`;
}
const newAttendees = attendeesList.split(",");
let newAttendeesOptional;
if ( attendeesOptionalList ) {
newAttendeesOptional = attendeesOptionalList.split(",");
}
if ( !attendeesOptionalList ) {
if ( attendeesList == "null" ) {
throw `attendeesList none.`;
}
} else {
if (( attendeesList == "null" ) && ( attendeesOptionalList == "null" )) {
throw `attendeesList and attendeesOptionalList none.`;
}
}
let accessLog = "";
//現時点のイベントデータ取得
let uri = "https://graph.microsoft.com/v1.0/me/events/" + eventId;
let response = httpClient.begin()
.authSetting( oauth2 )
.get( uri );
accessLog += "---GET request--- " + response.getStatusCode() + "\n";
accessLog += response.getResponseAsString() + "\n";
//engine.log("res:" + response.getResponseAsString());
const status = response.getStatusCode();
if( status >= 300 ){
engine.log(accessLog);
throw `Failed in GET request. status: ${status}`;
}
const jsonObj = JSON.parse( response.getResponseAsString() );
let attendees = jsonObj.attendees;
//イベントデータの更新
let length = attendees.length;
for (let i = 0; i < newAttendees.length; i++) {
let newAttendee = newAttendees[i];
attendees[length + i] = {};
attendees[length + i].emailAddress = {};
attendees[length + i].emailAddress.address = newAttendee;
}
if ( newAttendeesOptional ) {
length = attendees.length;
for (let i = 0; i < newAttendeesOptional.length; i++) {
let newAttendeeOptional = newAttendeesOptional[i];
attendees[length + i] = {};
attendees[length + i].emailAddress = {};
attendees[length + i].emailAddress.address = newAttendeeOptional;
attendees[length + i].type = "optional";
}
}
let requestObj = {};
requestObj.attendees = [];
requestObj.attendees = attendees;
engine.log("json:" + JSON.stringify( requestObj ));
let uri2 = "https://graph.microsoft.com/v1.0/me/events/" + eventId;
let response2 = httpClient.begin()
.authSetting( oauth2 )
.body( JSON.stringify( requestObj ), "application/json" )
.patch( uri2 );
accessLog += "---PATCH request--- " + response2.getStatusCode() + "\n";
accessLog += response2.getResponseAsString() + "\n";
const status2 = response2.getStatusCode();
if ( status2 >= 300 ) {
engine.log(accessLog);
throw `Failed in PATCH request. status: ${status2}`;
} else {
const eventUrl = jsonObj.webLink + "";
if ( dataId_eventUrl !== "" ) {
engine.setDataByNumber( dataId_eventUrl, eventUrl );
}
}
//// == ワークフローデータへの代入 / Data Updating ==
if ( dataId_log !== "" ) {
engine.setDataByNumber( dataId_log, accessLog );
}
Download
- Outlook-Calendar-Event-Attendees-Add-202307.xml
- 2023-07-03 (C) Questetra, Inc. (MIT License)
(Installing Addon Auto-Steps are available only on the Professional edition.)
Notes
- How to register applications on the Microsoft 365 (Azure Active Directory) side
- How to Setup HTTP Authentication on the Questetra side
- “How to Output Files from Cloud-based Workflow Questetra to OneDrive”
- 2.2: OAuth settings on the Questetra side
※ However, the scope is https://graph.microsoft.com/Calendars.ReadWrite offline_access
- 2.2: OAuth settings on the Questetra side
- “How to Output Files from Cloud-based Workflow Questetra to OneDrive”
Capture
