Problems using Python API and Cell History - note returning all user input.

CamG
CamG
edited 04/22/25 in API & Developers

I have been using the cell history to try and grab user input. The Input comes from users typing or selecting from a drop down. The data shows fine in Smartsheets. Dates are auto added but text e.g. "11k Production process complete" is user input when using the report/sheet in Smartsheets.

cell hisotry image.png

But then when I use this code to pull the cell history for one column.

import smartsheet as ss
smartsheet_client = ss.Smartsheet(SMARTSHEET_ACCESS_TOKEN)
SMARTSHEET_ACCESS_TOKEN = 'add yours here'
sheet = smartsheet_client.Sheets.get_sheet(sheet_id=paperbased)
for row in sheet.rows:
cell_history = smartsheet_client.Cells.get_cell_history(paperbased, row_id=row.id, column_id=current_task_col, include_all=True).to_dict()
for cell in cell_history['data']:
print(f"row_id: {row.id}, modified at: {cell['modifiedAt']}, value: {cell['displayValue']}")

I get this output which only gives me the value (user input) for the first row. But note it is giving the correct modified dates (compare with image above from Smartsheets above.)

row_id: 4735458228627332, modified at: 2021-01-25T10:36:28+00:00Z, value: 11k Production process complete
row_id: 4735458228627332, modified at: 2021-01-25T10:35:32+00:00Z, value: 0
row_id: 4735458228627332, modified at: 2021-01-25T10:31:24+00:00Z, value: 0
row_id: 4735458228627332, modified at: 2020-12-02T10:44:46+00:00Z, value: 0
row_id: 4735458228627332, modified at: 2020-12-02T10:37:56+00:00Z, value: 0
row_id: 4735458228627332, modified at: 2020-12-02T09:57:02+00:00Z, value: 0
row_id: 4735458228627332, modified at: 2020-12-02T09:56:34+00:00Z, value: 0
row_id: 4735458228627332, modified at: 2020-11-01T13:20:30+00:00Z, value: 0
row_id: 4735458228627332, modified at: 2020-08-05T15:01:10+00:00Z, value: 0

Note both 'displayValue' and 'value' are blank. I have tried this on a few different fields and sheets using this code.

I have also tried stripping the code back to a minimal example below. But the same problem.

response = (ss_client.Cells.get_cell_history(sheet_id=paperbased, row_id=4735458228627332, column_id=2389945628288900, include_all=True))

for hist in response.data:
print(hist)

Here is the output and again it is only showing the value for the first row.

cell history image2.png

If I dig into what is returned by get_cell_history. you get ['data'] and ['result'] which seem quite repetitive. Anyway you can see that modifiedAt is working so is modifiedBy. But 'displayValue' and 'Value' are only working the first time.

image.png

Does this functionality work for others? What am I doing wrong?

Tags:

Answers

NEW Smartsheet API Documentation - bookmark the updated link! https://developers.smartsheet.com