Google Group Member Addition

Add a member (email address) to Google Group. You can create an newsletter subscriber list (ML) distributed for the requester for material document, or register to group at the same time when adding a new employee account.

    A. Set OAuth2 Config Name (at [OAuth 2.0 Setting])Single-line inputRequired
    B. Select STRING/CHECKBOX for Group Address (Non-existent Error)Data selectString(single line)orSelect(check box)Required
    C. Select STRING DATA for Email to AddData selectString(single line)Required
    X. Select STRING DATA for Access Log (update)Data selectString(multiple line)
    -variable namevariable label
    Aconf_OAuth2Set OAuth2 Config Name (at [OAuth 2.0 Setting])
    Bconf_DataIdBSelect STRING/CHECKBOX for Group Address (Non-existent Error)
    Cconf_DataIdCSelect STRING DATA for Email to Add
    Xconf_DataIdXSelect STRING DATA for Access Log (update)
    // Google Group member add via Admin SDK Directory API (ver. 20170703)
    // (c) 2017, Questetra, Inc. (the MIT License)
    
    //// == 工程コンフィグの参照 / Config Retrieving ==
    var oauth2  = configs.get( "conf_OAuth2" ) + "";
    var dataIdB = configs.get( "conf_DataIdB" ); // (returns key)
    var dataIdC = configs.get( "conf_DataIdC" ); // (returns key)
    var dataIdX = configs.get( "conf_DataIdX" ); // (returns key)
    
    //// == ワークフローデータの参照 / Data Retrieving ==
    var targetGroups = [];
    var dataDefB = engine.findDataDefinitionByNumber( dataIdB );
    if( dataDefB.matchDataType("SELECT_CHECKBOX") ){
      var selectedGroups = data.get( dataIdB );
      for( var i = 0; i < selectedGroups.size(); i++ ){ // java.util.ArrayList
        var pushGroup = selectedGroups.get(i).getValue() + "";
        targetGroups.push( pushGroup );
      }
    }else{
      var pushGroup = data.get( dataIdB ) + "";
      targetGroups.push( pushGroup );
    }
    var memberEmail = data.get( dataIdC ) + "";
    
    //// == 演算 / Calculating ==
    var accessLog = "";
    var token = httpClient.getOAuth2Token( oauth2 );
    
    for( var i = 0; i < targetGroups.length; i++  ){ // javascript array
      var uri = "https://www.googleapis.com/admin/directory/v1/groups/" + targetGroups[i] + "/members";
      var requestObj = {};
      requestObj.email = memberEmail;
      requestObj.role = "MEMBER";
      var response = httpClient.begin()
        .bearer( token )
        .body( JSON.stringify( requestObj ), "application/json" )
        .post( uri );
      accessLog += "---POST request--- " + response.getStatusCode() + "\n";
      accessLog += response.getResponseAsString() + "\n";
    }
    
    //// == ワークフローデータへの代入 / Data Updating ==
    if( dataIdX !== "" ){
      retVal.put( dataIdX, accessLog );
    }
    

    • B’: Email address in Google Group stored in Data Item selected at config B
    • C’: Email address stored in Data Item selected at config C
    • Email address of C’ is registered to Google Group of B