Google Drive: Create Folder

Google ドライブ: フォルダ作成

This item creates a new folder in the specified folder on Google Drive.

Auto Step icon
Basic Configs
Step Name
Configs for this Auto Step
C1: User connects to Google Drive (must be App Administrator) *
C2: Parent Folder ID(When empty,create in My Drive root)#{EL}
C3: Folder Name to create *#{EL}
C4: Data Item that will save Folder ID
C5: Data Item that will save web view url of Folder


  • Users in C1 need to have a configured connection with Google Drive in [Account Settings] > [Google Connectivity]
    • Google Workspace Connectivity ([System Settings] > [Google Connectivity]) must be enabled on the workflow platform ([System Administrator Authorization] required )


See also

Script (click to open)
  • An XML file that contains the code below is available to download
    • google-drive-folder-create.xml (C) Questetra, Inc. (MIT License)
    • If you are using Professional, you can modify the contents of this file and use it as your own add-on auto step

function main() {
    let parentFolderId = configs.get("ParentFolderId");
    const folderName = configs.get("FolderName");
    if (folderName === "" || folderName === null) {
        throw "Folder Name is blank";

    const quser = configs.getObject("UserID");

    const json = createFolder(quser, parentFolderId, folderName);

    setData("FolderIdItem", json, "id");
    setData("WebViewUrlItem", json, "webViewLink");

 * ユーザーIDをチェックする
 * @param {QuserView} quser ユーザ
function checkUser(quser) {
    if (quser === null) {
        throw "User not found";

 * プロセスにデータを保存する
 * @param {String} configName 保存先データ項目の config 名
 * @param {Object} json 保存するデータをメンバに持つ JSON オブジェクト
 * @param {String} property 保存するデータのプロパティ名
function setData(configName, json, property) {
    const item = configs.get(configName);
    if (item === null || item === "") {
    const data = json[property];
    engine.setDataByNumber(item, data);

 * Google ドライブにフォルダを作成する
 * @param {QuserView} quser ユーザ
 * @param {String} parentFolderId 親フォルダのID
 * @param {String} name フォルダ名
 * @return {Object} jsonRes レスポンス本文の JSON オブジェクト
function createFolder(quser, parentFolderId, name) {
    let reqBody = {};
    //mime type of google drive folder
    reqBody["mimeType"] = "application/";
    if (parentFolderId !== "" && parentFolderId !== null) {
        reqBody["parents"] = [parentFolderId];
    reqBody["name"] = name;

    const url = "";

    const response = httpClient
        .googleOAuth2(quser, "Drive")
        .queryParam("fields", "id, webViewLink")
        .queryParam("supportsAllDrives", "true")
        .body(JSON.stringify(reqBody), "application/json; charset=UTF-8")
    const status = response.getStatusCode();
    const responseTxt = response.getResponseAsString();
    if (status >= 300) {
        const error = `Failed to create. status:${status}`;
        throw error;
    const jsonRes = JSON.parse(responseTxt);
    return jsonRes;