多选基础资料的取值和赋值原创
2人赞赏了该文章
1,167次浏览
编辑于2024年06月27日 16:11:16
DynamicObject load = BusinessDataServiceHelper.loadSingle("xyjt_asd", new QFilter[]{new QFilter("billno", QCP.equals, "wkl")});
获取多选基础资料 每一项就是一个DynamicObject
DynamicObjectCollection users = load.getDynamicObjectCollection("xyjt_much");
获取多选基础资料的List
List<DynamicObject> userList = new ArrayList<>();
for (DynamicObject user : users) {
DynamicObject userObj = user.getDynamicObject("fbasedataid");
userList.add(userObj);
}
新建一个空的单据
DynamicObject dynamicObject = BusinessDataServiceHelper.newDynamicObject("xyjt_asd");
获取新建单据的多选基础资料并赋值
DynamicObjectCollection userColl = dynamicObject.getDynamicObjectCollection("xyjt_much");
for (DynamicObject user : userList) {
DynamicObject newUser = new DynamicObject(userColl.getDynamicObjectType());
newUser.set("fbasedataId", user);
userColl.add(newUser);
}
多选基础资料字段赋值
dynamicObject.set("xyjt_much", userColl);
dynamicObject.set("billno","lkw");
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
save之后就会生成一个新的单据
赞 2
2人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读