To Setup Business Forms to be 'Auto Output' to Google Docs

With setting receive script (Google Apps Script) on Google Docs, Business forms can be generated automatically. You can dynamically generate business forms by sending required process data to Google Docs automatically from the 'Message Throwing Intermediate Event (HTTP)' which set in the middle of the Workflow. Data is sent securely in multipart/form-data encode (POST method).

There are several form generating system like this, among them, it can be implemented easily with Google Docs. This is the explanations how to generate forms in Google Docs automatically integrating to Questetra BPM Suite.

Preparation on Google Docs

Creating a Template of Forms

To start with, create a Spreadsheet as a template of forms in Google Docs.
You may create this from scratch, or you may upload Excel file if you have, and shape it later.

To Create Google Apps Script

Then, create Google Apps Script which receives external HTTP Request and automatically generates a Spreadsheet that HTTP request parameter Values are entered into particular cell of the template.

Google Apps Script is the script and its execution environment that can work various Google services in a unified manner. See Google Apps Script for the details.

Open the Spread sheet as a template, select [Tools], [Script Editor], then Google Apps Script Editor screen will be launched. Input the following codes there.

TEMPLATE_SPREADSHEET_ID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
PARAM_CELL_MAP = {
  "paramA": "B5",
  "paramB": "F4",
  "paramC": "A9"
};

function doGet(e) {
  createSheet_(e);
  return UiApp.createApplication();
}

function doPost(e) {
  createSheet_(e);
  return UiApp.createApplication();
}

function createSheet_(e) {
  var templateFile = DocsList.getFileById(TEMPLATE_SPREADSHEET_ID);
  var copiedFile = DocsList.copy(templateFile, templateFile.getName() + '_' +  e.parameter.id);

  var copiedSheet = SpreadsheetApp.open(copiedFile).getSheets()[0];
  for (var param in PARAM_CELL_MAP) {
    if (e.parameter[param]) {
      copiedSheet.getRange(PARAM_CELL_MAP[param]).setValue(e.parameter[param]);
    }
  }
}

There, what is specified in [TEPMLATE_SPREADSHEET_ID] is the ID of the template file, and it is the value that specified in the key parameter of URL to open template file in Google Docs.
And [PARAM_CELL_MAP] is the definition of which parameter of HTTP request goes to which cell of the Spreadsheet. Change these values according to your template Spreadsheet.

To Share as Service and to Enable

After creating Script, click [Share] on the script editor, select [Publish as Service], then a Pop-up comes out. Copy the [URL] , then check [Allow anyone to invoke this service] , [Allow anonymous access], and [Enable Service], then click [Save]. Now, this script is capable to process HTTP request to the URL that you have copied.
Now, this script is capable to process HTTP request to the URL that you have copied.

At that time, a screen which requests you for permission to access to Google Docs and Google Spreadsheet will be displayed. Enter yes to it.

Confirmation with Web Browser

Suppose the URL that this script receives is :

https://docs.google.com/a/macros/questetra.com/exec?service=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

a form out from template will be generated in the Google Docs by accessing to the following URL.

https://docs.google.com/a/macros/questetra.com/exec?service=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&id=1&paramA=15&paramB=foo&paramC=bar

For a precaution, try to access with Web browser to verify that the form files are generated in the Google Docs.

 

Preparation on Questetra BPM Suite

Now, preparation on Google docs are done so far. Next, prepare on Questetra BPM Suite.

Message Throwing Intermediate Event

To send HTTP request to the external in the middle of a process from Questetra BPM Suite, use Message Throwing Intermediate Event (HTTP).
See Message Throwing Intermediate Event (HTTP) for the detail.

Open the property of Message Throwing Intermediate Event in the Process Modeler, enter "id" in [Send Parameter Name] on [Process ID*] row of [Send Parameter Names of Process Data] table. And enter the names according to the script you created into [SEND Parameter Name] as you want to be reflected in the Google Docs forms.

To Try Running the Actual Process

Now, preparation on Questetra BPM Suite are also done. Activate the process model, and start it for trial. When the process reaches to Message Throwing Intermediate Event, forms will be generated in Google Docs.

Note that in this sample, anyone who knows the URL can generate forms in Google Docs. And values are not entered correctly in the Table type. We are going to explain the countermeasures for them in another article.