Search code examples
pythonsmartsheet-api

Smartsheet CHECKBOX Cells Always Returned as Empty


Whenever I retrieve a SmartSheet row and loop through the cells within it, all cells of type CHECKBOX always have a displayValue or value of Null, regardless of the status of the checkbox on the sheet. Has anyone else experienced this? (I am using their python sdk)


Solution

  • I believe you've found a bug with the Python SDK.

    Kevin's answer correctly describes the behavior of the API itself, as I verified (using Postman), via the following request / response.

    Get Row - Request:

    GET https://api.smartsheet.com/2.0/sheets/7359436428732292/rows/863888846677892
    

    Get Row - Response:

    {
      "id": 863888846677892,
      "sheetId": 7359436428732292,
      "rowNumber": 1,
      "version": 88,
      "expanded": true,
      "accessLevel": "OWNER",
      "createdAt": "2016-07-06T22:21:58Z",
      "modifiedAt": "2016-07-27T01:50:46Z",
      "cells": [
        {
          "columnId": 4509804229093252,
          "value": true
        },
        ...
      ]
    }
    

    In the example Response above, the cell contains a Checkbox that is selected (value=true). So the API itself is behaving properly.

    However, if I use the Smartsheet Python SDK to examine the exact same cell, the value attribute is being incorrectly set to null:

    Python code:

    import os
    import smartsheet
    
    os.environ['SMARTSHEET_ACCESS_TOKEN'] = 'MY_TOKEN_VALUE'
    smartsheet = smartsheet.Smartsheet()
    
    # get sheet
    sheet = smartsheet.Sheets.get_sheet(7359436428732292)
    
    print('SheetId:\n' + str(sheet.id) + '\n')
    print('RowId:\n' + str(sheet.rows[0].id) + '\n')
    print('ColumnId (for the checkbox column):\n' + str(sheet.columns[0].id) + '\n')
    print('Column object (for the checkbox column):\n' + str(sheet.columns[0]) + '\n')
    print('Cell that contains a selected Checkbox:\n' + str(sheet.rows[0].cells[0]))
    

    This code generates the following output:

    SheetId:

    7359436428732292
    

    RowId:

    863888846677892
    

    ColumnId (for the checkbox column):

    4509804229093252
    

    Column object (for the checkbox column):

    {"index": 0, "locked": null, "systemColumnType": null, "autoNumberFormat": null, "symbol": null, "format": null, "primary": null, "options": [], "filter": null, "width": 75, "lockedForUser": null, "title": "CBcol", "hidden": null, "type": "CHECKBOX", "id": 4509804229093252, "tags": []}
    

    Cell that contains a selected Checkbox:

    {"format": null, "displayValue": null, "linksOutToCells": null, "columnType": null, "columnId": 4509804229093252, "hyperlink": null, "value": null, "conditionalFormat": null, "strict": true, "formula": null, "linkInFromCell": null}
    

    So, unfortunately, it seems that the Python SDK isn't properly setting value for Checkbox columns (or for Symbol columns like "Star" that behave like checkbox columns). I'd suggest that you log this issue here, so that Smartsheet is aware and can address it. If you're able to fix the issue locally (i.e., by modifying your local copy of the smartsheet-python-sdk package), then you can also submit a pull request.