Microsoft365: Get List (for Paging)

Microsoft365: Get List (for Paging)
Retrieves a certain listing on the next page in Microsoft365. The acquired data is appended to a String-type multi-line Data Item. (When acquiring a list, there is a limit to the number of items that can be acquired at one time, and it may be necessary to divide the list into multiple pages)
Configs
  • A: OAuth2 Setting *
  • B: next link URL from before *
  • C: Data List (update) *
  • D: Data Key Name *#{EL}
  • E: next link URL for after (update)
  • X: Access Log (update)
Script (click to open)


// Get Microsoft365 Group Member List via Microsoft Graph API v1.0 (ver. 202211)
// (c) 2022, Questetra, Inc. (the MIT License)

//// == Config Retrieving ==
const oauth2  = configs.get( "conf_OAuth2" ) + "";

const nextLink = engine.findDataByNumber(configs.get( "conf_nextLink" )) + "";
const keyName = configs.get( "conf_keyName" ) + "";

const dataId_list     = configs.get( "conf_list" );
const dataId_nextLink2 = configs.get( "conf_nextLink2" );
const dataId_log      = configs.get( "conf_log" );

//// == Calculating ==
let accessLog = "";
let uri = nextLink;
let response = httpClient.begin()
  .authSetting( oauth2 )
  .get( uri );
accessLog += "---GET request--- " + response.getStatusCode() + "\n";
accessLog += response.getResponseAsString() + "\n";


//// == Data Updating ==
const status = response.getStatusCode();

if( status >= 300 ){
  engine.log(accessLog);
  throw `Failed in DELETE request. status: ${status}`;
} else {
  const jsonObj = JSON.parse( response.getResponseAsString() );
  const values = jsonObj.value;
  //既存リストを取得して追記
  let list = engine.findDataByNumber( dataId_list) + "";
  for (let i = 0; i < values.length; i++) {
    let value = values[i];
//    list += value.mail + "\n";
    list += value[keyName] + "\n";
  }
  engine.setDataByNumber( dataId_list, list );

  if( dataId_nextLink2 !== "" ){
    engine.setDataByNumber( dataId_nextLink2, jsonObj['@odata.nextLink'] );
  }

}
if( dataId_log !== "" ){
  engine.setDataByNumber( dataId_log, accessLog );
}

Download

2022-11-02 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/microsoft365-list-get-paging/
The Addon-import feature is available with Professional Edition
Freely modifiable JavaScript (ECMAScript) code. No warranty of any kind.

Notes

Capture

See also

Scroll to Top

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading