I have the following code that has been working properly for quite sometime. It adds links to multiple sheets and cells. It is run from an account that has ADMIN access (and I can perform the desired functions in the UI successfully).
#############ORIGINAL CODE#################
def set_sheet_link(ss_client, source_sheet_id, source_row_id, source_column_id, dest_sheet_id, dest_row_id, dest_column_id):
cell_link = ss_client.models.CellLink()
cell_link.sheet_id = source_sheet_id
cell_link.row_id = source_row_id
cell_link.column_id = source_column_id
cell = ss_client.models.Cell()
cell.column_id = dest_column_id
cell.value = ss_client.models.ExplicitNull() # Must use the SmartSheet "null" value
cell.link_in_from_cell = cell_link
row = ss_client.models.Row()
row.id = dest_row_id
row.cells.append(cell)
ss_client.Sheets.update_rows(dest_sheet_id, [row])
return
##############################
I have a new requirement to add a link to another sheet. This other sheet tracks presales efforts. The value of the cell to be assigned a link (in) is from a pick list (validation is on). At the time that presales turns a project over to the delivery team, this Python script (the function above is part of that larger script) is used to set up a new project instance. The value of the cell will move from a selection from a pick list to being a link from the project delivery side; thus, I need to override the validation when I assign the link. I updated the code function from above to below (mods bolded):
#############UPDATED CODE#################
def set_sheet_link(ss_client, source_sheet_id, source_row_id, source_column_id, dest_sheet_id, dest_row_id, dest_column_id):
cell_link = ss_client.models.CellLink()
cell_link.sheet_id = source_sheet_id
cell_link.row_id = source_row_id
cell_link.column_id = source_column_id
cell = ss_client.models.Cell()
cell.column_id = dest_column_id
cell.overrideValidation = True # Override the data validation on the cell/column
cell.strict = False # False value required to support override of validation
cell.value = ss_client.models.ExplicitNull() # Must use the SmartSheet "null" value
cell.link_in_from_cell = cell_link
row = ss_client.models.Row()
row.id = dest_row_id
row.cells.append(cell)
ss_client.Sheets.update_rows(dest_sheet_id, [row])
return
##############################
The updated code gets the following error:
{"response": {"statusCode": 400, "reason": "Bad Request", "content": {"detail": {"attribute": "cell.strict", "index": 0, "rowId": 4986636077623172}, "errorCode": 1115, "message": "Row must contain either cell link updates or row/cell value updates; mixing of both update types in one API call is not supported.", "refId": "khyxyh"}}}
If I omit the line: cell.value = ss_client.models.ExplicitNull(), I get an error indicating that cell.value must be set to null.
Any help would be greatly appreciated!
-Kevin