动态创建单据体和子单据体原创
金蝶云社区-Cchen
Cchen
7人赞赏了该文章 1,449次浏览 未经作者许可,禁止转载编辑于2023年12月21日 11:09:16
DynamicObjectCollection entryEntitys = this.getModel().getEntryEntity("单据体标识");
entryEntitys.clear();
DynamicObject newentryEntity = entryEntitys.addNew();

newentryEntity.set("字段标识",billno);

//获取子单据体

DynamicObjectCollection newsubentryentitys = newentryEntity.getDynamicObjectCollection("子单据体标识");

newsubentryentitys.clear();

DynamicObject newsubentryentity = newsubentryentitys.addNew();
newsubentryentity.set("子单据体字段标识",value);
this.getView().updateView("单据体标识");   //刷新分录

this.getView().updateView("子单据体标识");   //刷新分录

------------------------以上方法赋值基础资料的时候  必须给基础资料类型  不然刷新会报错------------

-----------------------如果基础资料只有id用一下方式---------------------

  
this.getModel().deleteEntryData("单据体标识");
this.getView().updateView("子单据体标识");   //刷新子单据体

int rowIndex = this.getModel().createNewEntryRow("单据体标识");

this.getModel().setValue("字段标识",billno,rowIndex);

DynamicObject Entryentity = this.getModel().getEntryRowEntity("单据体标识", rowIndex);
DynamicObjectCollection dynamicObjectCollection = Entryentity.getDynamicObjectCollection("子单据体标识");
dynamicObjectCollection.clear();
// int subentryentityrow = this.getModel().createNewEntryRow("子单据体标识""); ---这种创建的 赋值一直报角标越界 改用下面方式创建子单据体行

 DynamicObject dynamicObject = dynamicObjectCollection.addNew();    

 this.getModel().setValue("字段标识",value,dynamicObjectCollection.size()-1,rowIndex);

this.getView().updateView("单据体标识");   //刷新分录
this.getView().updateView("子单据体标识"");   //刷新分录


赞 7