场景:
在一张单据中上传了一个附件,通过代码同步到另一张单据中
思路:
AttachmentServiceHelper 接口实现
实现:
//查数据
DynamicObject object = QueryServiceHelper.queryOne("kdec_fileyuanbi", "Id", new QFilter("billno",QCP.equals,"0005").toArray());
//查附件
List<Map<String, Object>> ll = AttachmentServiceHelper.getAttachments("kdec_fileyuanbi", object.get("Id"), "attachmentpanel", false);
for (Map<String, Object> map : ll) {// 时间戳转long 否则报错
Timestamp lastModified = (Timestamp)map.get("lastModified");
map.put("lastModified", lastModified.getTime());
}
//查目标单数据
DynamicObject object1 = QueryServiceHelper.queryOne("kdec_wpstest", "Id", new QFilter("billno",QCP.equals,"001").toArray());
//上传附件
AttachmentServiceHelper.upload("kdec_wpstest", object1.get("Id"), "attachmentpanel", ll);
推荐阅读