如何在 Smartsheet Python SDK 中更新 Predecessor 或 PredecessorList 对象

How to update Predecessor or PredecessorList Object in Smartsheet Python SDK

我有一个创建父行和可变数量的子行的循环。我想用先前的子行号更新子行的 Predecessor 字段(当添加多个子行时)。我很难将 2 个必需的参数添加到 'cell.object_value' 对象(object_type 和前任)。

for key, value in record.items():    
    new_cell = ss.models.Cell()
    if k == 'Predecessors':
        pred = []
        pred_update = {}
        pred_update['rowId'] = predecessor_row_id
        pred_update['type'] = 'FS'
        pred.append(pred_update)

        row = ss.Sheets.get_row(sheet_id, predecessor_row_id)
        new_cell.object_value = str(row.row_number)
        new_cell.object_value.predecessors = pred
        new_cell.object_type = "PREDECESSOR_LIST"

编辑: 代码运行没有错误,但是 new_cell.object_value.predecessors 参数中包含的信息未传输到 SmartSheet。

predecessorsobject value的属性,不是直接的单元格。

new_cell.objectValue.predecessors = pred

设置前辈有点棘手。你走在正确的轨道上。但是,当您在单元格上设置值时,只需设置 object_value。像这样:

# init the object_value for predecessor cell
pred_cell.object_value = ss_client.models.ObjectValue()

# set the object_type to PREDECESSOR_LIST
pred_cell.object_value.object_type = "PREDECESSOR_LIST"

# set the object_value for the cell with the PredecessorList
pred_cell.object_value = pred_list

可以找到操作的完整要点here