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)
3 Answers
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.

- 13,125
- 2
- 16
- 21
It's possible for the value of any cell to be null if the cell has never had any value set (e.g. if you add a value to a cell in a new row, all the other cells will be null). I'm guessing that's what you're seeing.
If you check one of those checkbox cells, save, then uncheck it, you should see its value as false
in the API.
For the purposes of your program logic, you can treat any null checkbox cells as unchecked.

- 76
- 3
in the cell.py file of the smartsheet library, replace the old:
@value.setter
def value(self, value):
if isinstance(value, six.string_types):
self._value = value
with:
@value.setter
def value(self, value):
if isinstance(value, six.string_types) or value is True:
self._value = value

- 142
- 6