The Smartsheet module provides a service to easily interact with Smartsheet's REST API. The module also support submission of form data directly to Smartsheet for developers.
The 2.x branch of this module only supports the 2.0 version of the Smartsheet API. The 1.x branch supports the 1.0 version, but it has officially been dropped by Smartsheet so you probably shouldn't use it.
Installation
Install as you would normally install a contributed Drupal module. See https://www.drupal.org/docs/8/extending-drupal-8/installing-drupal-8-mod... for further information.
Drupal 8
Configuration
A valid Smartsheet access token is required for the module to work. It can be generated within the Smartsheet webapp (https://app.smartsheet.com/b/home).
With the previously generated token, the access_token configuration key needs to be set in the smartsheet.config namespace. It can be done by two different ways:
- In the settings.php file, like this:
$config['smartsheet.config']['access_token'] = <GENERATED TOKEN> - In the administration UI, a configuration interface is available at "Administration » Configuration » Web services » Smartsheet API (admin/config/services/smartsheet).
Usage
API
The module provides the smartsheet.client service that interfaces directly the Smartsheet's REST API. This service offers these four methods:
$instance->get($path, $options); // GET request
$instance->post($path, $data, $options); // POST request
$instance->put($path, $data, $options); // PUT request
$instance->delete($path, $options); // DELETE request
The $data array is the body of the POST or PUT request to send to the Smartsheet API.
The $options array is passed directly to the Guzzle request. Use it for example to add query string to the URL.
For further documentation about the Smartsheet REST API got to https://smartsheet-platform.github.io/api-docs/
Forms support
This module also offers the possibility to add values submitted by a custom form (built with Form API) as a new row to a sheet. To use this feature, add the following properties to your form:
$form['#smartsheet_sheet_id'] = <SMARTSHEET ID>;Where<SMARTSHEET ID>is the ID of the sheet inside which the values are to be inserted.$form['#smartsheet_column_mapping'] = <FIELD MAPPING>;Where<FIELD MAPPING>is an associative array whose keys are form field names and values are the matching column title of ids from the sheet. Each mapped value submitted in the form will be inserted in the matching column. For example:
$form['#smartsheet_column_mapping'] = [ 'firstname' => 'First Name'; 'lastname' => 'Last Name'; 'email' => 4074863598216325; ];
Drupal 7
Requirements
The xautoload module is required to automatically load the appropriate class.
Configuration
For Drupal 7, the configuration variable holding the token is 'smartsheet_access_token'. You can set it the same way as with Drupal 8 but to access the admin UI, you will have to enable the module smartsheet_ui.
Usage
API
As services are not available with Drupal 8, the SmartsheetAPI custom class is provided. An instance of the class can be created and retrieved with the static SmartsheetAPI::instance() method. This instance can then be used with these four methods:
$instance->get($path, $parameters); // GET request, parameters optionals
$instance->post($path, $parameters); // POST request, parameters required
$instance->put($path, $parameters); // PUT request, parameters required
$instance->delete($path); // DELETE request, no parameters
See the in-code documentation of the SmartsheetAPI class for more information and examples.
For further documentation about the Smartsheet REST API got to https://www.smartsheet.com/developers/api-documentation.
Forms support
The module also provides a submit callback to insert values from a form into a sheet as a new row. To use it, just add three properties to your form:
$form['#submit'][] = 'smartsheet_form_submit'; // Note: with Drupal 7, to activate the submit callback, you have to explicitely add it to your form$form['#smartsheet_sheet_id'] = <SMARTSHEET ID>;Where<SMARTSHEET ID>is the ID of the sheet inside which the values are to be inserted.$form['#smartsheet_column_mapping'] = <FIELD MAPPING>;Where<FIELD MAPPING>is an associative array whose keys are form field names and values are the matching column title of ids from the sheet. Each mapped value submitted in the form will be inserted in the matching column. For example:
$form['#smartsheet_column_mapping'] = array( 'firstname' => 'First Name'; 'lastname' => 'Last Name'; 'email' => 4074863598216325; );
Project information
- Project categories: Developer tools, Integrations
- Created by pbuyle on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.



