如何修复:linksOutToCells[]不允许用于update\u rows()操作

2024-04-24 17:12:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Smartsheet Python SDK并尝试更新Smartsheet中的行,其中许多要更新的单元格都有指向其他工作表的现有链接。我想用数据更新单元格值,同时保持链接完整。当我尝试用新的单元格值更新行时(但是保持原始links_out_to_cells对象附加到原始单元格),我得到了API错误1032:"The attribute(s) cell.linksOutToCells[] are not allowed for this operation."有人知道解决这个问题的好方法吗?你知道吗

这里是我的evaluate_row_and_build_updates函数(传入smartsheet行和pandas df中的行——smartsheet中每一行的第一个值将在更新时保留)

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

Tags: andbuilddfnewfor链接cellss
1条回答
网友
1楼 · 发布于 2024-04-24 17:12:46

在请求更新链接的源单元格上的单元格值时,不必包含linksOutToCells对象。只需更新单元格值即可。到其他工作表的链接将保持不变,并且您添加的新单元格值将链接到其他工作表。 可能是这样的:

# 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])

在链接断开的单元格上运行该代码将保持单元格链接。你知道吗

相关问题 更多 >