Pneumatic workflows allow you to add multiple custom data fields to the kickoff form and each stage of the process. What if I told you how you could get the values of those data fields from outside Pneumatic and put them, for example, in a Google Sheets spreadsheet in tabulated format? You can do that by taking advantage of Pneumatic’s public API.
Set up your Environment
We’ve prepared a Google Sheets spreadsheet for you with an AppScript that accesses Pneumatic’s Public API using an API key and template ID that you supply.
It’s shared as a view-only spreadsheet, so you need to make your own copy of it, before you begin.
Finding your API Key and Template ID
For the script to run properly you need to supply your api key and a template id, as it gets data field values for workflows based on a specific template. You find your API key on your integrations page. Just copy and paste it into the spreadsheet.
The next bit of information you need to supply is a template ID, go into templates, select a template that you want to get data fields from and look at the URL for the template:
The template ID is the numerical code before the last slash in the URL, just copy that and enter it into the spreadsheet under the API key. Just copy it and paste it into the third row in the spreadsheet, add a comma and then another api field name and so forth.
Finding your Field IDs
The last bit of information you need is a comma separated list of the api names of the data fields you want to get the values of.
I know, this may sound a tad intimidating but you can actually find those in your interface too. On the template editing page, open up the kickoff form or the task that has the fields you are interested in, then go into the hamburger menu on the right, the API name of the field is the first item on the list that opens.
Just copy it and paste it into the third row in the spreadsheet, add a comma and then another api field name and so forth.
If you try running either script in the spreadsheet, Google is going to ask you for permission to run them, give the permission by clicking on Allow.
Running the Sample App Script
Once you’ve supplied all this information just click on Get Data Fields and the script will populate the 4th row with the names of the fields as you defined them, while the other rows will contain the names of the workflows and the values for the fields:
Note that the first time you try running the Script Google is going to ask you for permission to run it, so click on Allow and then click on the Button again.
You can find the script itself by going to Extensions —> Apps Script
The script that is assigned to the Get Data Fields button is named showFieldValues, you can look at and modify it to your heart’s content:
It gets the values that you enter in the spreadsheet, then puts together a config object and a params object, the params object is then turned into a queryString and added to the apiUrl parameter. The script then executes a fetch request on the UrlFetchApp object.
It then loops over the parsed results of the request to retrieve the values for the data fields. When getting the values for the first row it also gets the names for the columns (that’s what the if statement inside the inner for loop is for).
Launching Multiple Workflows from Google Sheets
Learn how to use Pneumatic’s API to launch multiple workflows in Pneumatic programmatically based on tabulated data in a Google Sheets spreadsheet.
The file also contains several other sample scripts that get data from the Pneumatic API. All of these get the templateId and the API key from the spreadsheet and then just console-log the results into the execution log. That way you can see what kind of data you can get by accessing the various end points of the Pneumatic API.