API无法正确更新附件数组内的多个值
Python SDK
使用field ID更新的代码如下:
在查询获得record的时候,record里的数据都是fieldname表示的,而不是fieldid,我用fieldid去判断对应的字段是否为空,是无法正确判断的,第一个print的结果如下,红框是要更新的字段
第二个print结果如下
显示新增了一个fieldID的字段,而不是更新'白底图'的数组
然后我再对这条记录查询一次,会发现'白底图'的内容被更新成了'fldkt4vmm79Uv'的内容,原来白底图的内容丢失。
然后我就尝试不用fieldid,直接用fieldname,代码修改成
重新测试。第一次print打印出原始的记录内容
第二次print打印出更新后的记录内容,能看到数组里有两条记录
但是重新根据skuid查询后发现,实际记录数组里还是只有一个
所以Python的sdk下到底应该怎么更新一个数组字段的值?
补充:上述的代码中,获取datasheet的方式始终均为:datasheet = vika.datasheet("*********", field_key="id")
record.fldxxxxx = [*record.fldxxxxx, new_file]
record.fldxxxxx = [*record.fldxxxxx, new_file]
But record.fldxxxx is None, there is only field name , such as record.白底图
record.fldxxxxx = [*record.fldxxxxx, new_file]
But record.fldxxxx is None, there is only field name , such as record.白底图
new_file = datasheet.upload_file(local_file_path)
record = records[0]
if record.files is None:
record.files = [new_file]
elif new_file and new_file not in record.files:
record.files = record.files + [new_file]