Acquire the Storage Folder URL after Automatic Processing Step(Google Drive Integration)

I will describe how to acquire the storage folder URL via Google Apps Script after the automatic processing step (Google Drive integration).

Happy New Year!

We are going to introduce how to use Questetra BPM Suite full throttle this year too.

This time, I would like to talk about Google Drive integration.

In September 2016, “Google Apps for Work” changed its name to “G Suite”.

All together now. Introducing G Suite.
And today, we’re introducing a new name that better reflects this mission: G Suite.
G Suite is a set of intelligent apps—Gmail, Docs, Drive, Calendar, Hangouts, and more—designed to bring people together, with real-time collaboration built in from the start.

(I think) the future version upgrade is expected, and the usage of “G Suite” is increasing even by companies using Questetra.
(So?) the usage of Google drive collaboration function of Questetra is increasing as well.

Auto Backup to Google Drive
By placing “Service Task (Google Drive)”, Auto-backup to Google Drive, in the middle of a flow, File type data is automatically backed up to Google Drive at the moment the issue arrives to it. For example, you can transfer ‘Invoice PDF which has been approved by the supervisor’ to Google Drive automatically.

The more customers use it, the more requests come up.

◆Background and Requests for Use of Automatic Processing Process (Google Drive Integration)

The background for using Google Drive integration campe up from the following needs

* managing all the files created on business using Google Drive collectively
* By managing files with Google Drive, we want to make navigation and searchability easier

I see. Oh that makes sense!

Among those requests, we had a slightly different one.

* We would like to have the URL of a folder containing the file saved in Google Drive as a data item of a process (managed in Questetra).

Analyzing the request further,

* The file type data item (managed in Questetra) requires to be downloaded one by one at the time when we want to browse the file. (It’s a hassle)
* Especially, for cases where there are multiple files, we want to use the Google Drive Viewer. (Easier to browse)

I will introduce an example to deal with such a request.

◆The Case of (Google Drive) Stored Folder URL Acquisition Implementation


The case example is implemented by Google Apps Script using Throwing Message Intermediate Event (HTTP).


<Google Apps Script Implementation Example>

function doGet(e) {
  var folderName = e.parameter.folderName  // Retrieve the folder name of the search target
  var folders = DriveApp.getFoldersByName(folderName)  // Search for folder name
  while (folders.hasNext()) {
    var folder =
  return ContentService.createTextOutput(folder.getUrl())  // Return the target folder URL

The main consideration is that

* the stored folder name is set unique to the process (executed on Questetra).
(The example sets {process start date}–{process ID} as the storage folder name.)

As you can see from the implementation example of Google Apps Script and Class Reference (see below), you cannot identify the corresponding storage folder from the folder path. (I will skip the details)
Then we use the only getFoldersByName() method which is available.
However, since it allows the same folder name, the multiple folder objects will be retrieved when the same folder name exists.
To avoid such cases, we make the storage folder name is unique.

<Google Apps Script file / Folder access Class Reference>
* getFoldersByName(name)



We would be happy if you could take advantage of G Suite together with Questetra BPM Suite more.

At first I thought “It’s easy to implement!”, but it turned out to be more complicated.
In addition, although I did not mentioned details, the current implementation is lacking in terms of security.
(The permission to execute Google Apps Script is set as executable permission if you have the URL)

This implementation does URL acquisition by accessing Google Apps Script implemented in the Google Document.
To ensure security, it requires implementing access via OAuth authentication.
Though we have omitted the details from the description this time, please keep it in mind when you implement it.

Please feel free to contact us if you have any questions.


About Masato Furukubo

Questetra, Inc. Sales Department
View all posts by Masato Furukubo

Prev article - 50. Questetra Tips How to Change Filenames Automatically following the Rule
Next article - 50. Questetra Tips Automate Processing by Accessing its Own API
Another article - Masato Furukubo How to do Multilingual Support of a Process Data Item Name in the Input Screen?