0

I'm using the Smartsheet Python SDK and attempting to update rows in a smartsheet in which many of the cells to be updated have existing links out to other sheets. I want to update the cell values with data from a pandas df, while keeping the links out intact. When I attempt to update_rows with new cell values (but keeping the original links_out_to_cells object attached to the original cell), I get API Error 1032: "The attribute(s) cell.linksOutToCells[] are not allowed for this operation." Does anyone know a good workaround for this issue?

Here is my evaluate_row_and_build_updates function (passing in the smartsheet row and the row from the pandas df -- the first value in each row in the smartsheet is meant to be preserved with the update)

def evaluate_row_and_build_updates(ss_row, df_ro):
    new_row = smartsheet.models.Row()
    new_row.id = ss_row.id
    new_row.cells = ss_row.cells

    empty_cell_lst = list(new_row.cells)[1:]
    for i in range(len(empty_cell_lst)):
        empty_cell_lst[i].value = df_row[1][i]

    return new_row

1 Answers1

0

When making the request to update the cell values on the source cells for the links you don't have to include the linksOutToCells object. You can just update the cells value. The link out to the other sheet will stay in place and the new cell value you added will be linked out to the other sheets. It could look like this:

# Build new cell value
new_cell = smartsheet.models.Cell()
new_cell.column_id = <COLUMN_ID>
new_cell.value = "testing"

# Build the row to update
new_row = smartsheet.models.Row()
new_row.id = <ROW_ID>
new_row.cells.append(new_cell)

# Update rows
updated_row = smar_client.Sheets.update_rows(
  <SHEET_ID>,
  [new_row])

Running that code on a cell that has a link going out will keep the cell link in place.

daveskull81
  • 627
  • 4
  • 7