Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Download Tracker 1.0.7 — Minor update available for module download_tracker (1.0.7). Release: Directory2Block Slideshow 1.0.8 — Minor update available for module directory2block_slideshow (1.0.8). Release: Mautic Audiences 1.1.5 — Minor update available for module mautic_audiences (1.1.5). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

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;
    );
    

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Jul 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core Release date
3.0.x-dev Dev Jul 13, 2024