Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API无法正确更新附件数组内的多个值 #52

Open
flying-dolphin opened this issue Oct 27, 2023 · 4 comments
Open

API无法正确更新附件数组内的多个值 #52

flying-dolphin opened this issue Oct 27, 2023 · 4 comments

Comments

@flying-dolphin
Copy link

Python SDK
使用field ID更新的代码如下:
img_v2_b3e68128-7cc6-4eac-9e1a-9a45606a239g
在查询获得record的时候,record里的数据都是fieldname表示的,而不是fieldid,我用fieldid去判断对应的字段是否为空,是无法正确判断的,第一个print的结果如下,红框是要更新的字段
32664d31-bd6b-4e5a-a506-5a3c04d8292d
第二个print结果如下
be6038d2-e5e9-40db-b02b-78b7c9a37f30
显示新增了一个fieldID的字段,而不是更新'白底图'的数组
然后我再对这条记录查询一次,会发现'白底图'的内容被更新成了'fldkt4vmm79Uv'的内容,原来白底图的内容丢失。
16cfb6e4-9c5b-48e6-9137-07d4bd785e69

然后我就尝试不用fieldid,直接用fieldname,代码修改成
5e55588d-da67-47b5-a74d-b05890c1d513
重新测试。第一次print打印出原始的记录内容
a4dd17b5-b3a7-47e0-87c6-42ac6ef7d696

第二次print打印出更新后的记录内容,能看到数组里有两条记录
bd09a5e2-3f9f-44a3-8cac-5f4d58a551d1
但是重新根据skuid查询后发现,实际记录数组里还是只有一个
b0509bd6-ddfe-447c-8367-2e8e8d627904

所以Python的sdk下到底应该怎么更新一个数组字段的值?

@flying-dolphin
Copy link
Author

补充:上述的代码中,获取datasheet的方式始终均为:datasheet = vika.datasheet("*********", field_key="id")

@mayneyao
Copy link
Contributor

record.fldxxxxx = [*record.fldxxxxx, new_file]

@flying-dolphin
Copy link
Author

record.fldxxxxx = [*record.fldxxxxx, new_file]

But record.fldxxxx is None, there is only field name , such as record.白底图

@mayneyao
Copy link
Contributor

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants