Microsoft365 Group ID Get
Gets a Microsoft365 group ID by specifying the display name.
Configs for this Auto Step
- conf_OAuth2
- A: OAuth 2.0 Setting *
- conf_displayName
- B: Group Display Name *#{EL}
- conf_groupId
- C: Group ID (Update) *
- conf_log
- X: Access Log (update)
Script (click to open)
// Get Microsoft365 Group List via Microsoft Graph API v1.0 (ver. 202210)
// (c) 2022, Questetra, Inc. (the MIT License)
//// == 工程コンフィグの参照 / Config Retrieving ==
const oauth2 = configs.get( "conf_OAuth2" ) + "";
const displayName = configs.get( "conf_displayName" ) + "";
const dataId_groupId = configs.get( "conf_groupId" );
const dataId_log = configs.get( "conf_log" );
//// == 演算 / Calculating ==
let accessLog = "";
let uri = "https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName,'" + encodeURI(displayName) + "')";
let response = httpClient.begin()
.authSetting( oauth2 )
.get( uri );
accessLog += "---GET request--- " + response.getStatusCode() + "\n";
accessLog += response.getResponseAsString() + "\n";
//// == ワークフローデータへの代入 / Data Updating ==
const status = response.getStatusCode();
let groupId = "";
if( status >= 300 ){
engine.log(accessLog);
throw `Failed in GET request. status: ${status}`;
} else {
const jsonObj = JSON.parse( response.getResponseAsString() );
const values = jsonObj.value;
for (let i = 0; i < values.length; i++) {
let value = values[i];
if (value.displayName == displayName) {
groupId = value.id;
engine.setDataByNumber( dataId_groupId, groupId );
}
}
}
if (groupId == "") {
throw `specified group None`;
}
if( dataId_log !== "" ){
engine.setDataByNumber( dataId_log, accessLog );
}
Download
- Microsoft365-Group-Id-Get-By-Name-202307.xml
- 2023-07-03 (C) Questetra, Inc. (MIT License)
(Installing Addon Auto-Steps are available only on the Professional edition.)
Notes
- About link settings with Microsoft 365 series services
- How to register an application on the Microsoft365 (Azure Active Directory) side
- How to set HTTP authentication on Questetra side
- How to Output Files from Cloud-based Workflow Questetra to OneDrive
- 2.2: OAuth settings on the Questetra side
- However, the scope should be either one of the following
- http s://graph.microsoft.com/GroupMember.Read.All offline_access
- http s://graph.microsoft.com/Group.Read.All offline_access
- http s://graph.microsoft.com/Directory.Read.All offline_access
- http s://graph.microsoft.com/Group.ReadWrite.All offline_access
- http s://graph.microsoft.com/Directory.ReadWrite.All offline_access
- How to Output Files from Cloud-based Workflow Questetra to OneDrive
Capture
