Dynamic CRM 组织服务对Word模版生成附件

目的:解决用户手动下载word模版再上传问题

解决方案:组织服务对指定word模版生成附件并保存到注释实体中。

1.word模版必须上传到系统文档模版后:设置->模版->文档模版

2.组织调用“SetWordTemplate”,另外实体信息需要把“注释”勾选上,否则执行代码会报错,如下:

 

3.代码如下:

OrganizationRequest request = new OrganizationRequest("SetWordTemplate");
request["Target"] = new EntityReference(entityname, 实体记录ID); 
request["SelectedTemplate"] = new EntityReference("documenttemplate", 模版Id); // 模版ID=第一步上传的文档模版记录ID
OrganizationResponse response = (OrganizationResponse)crmService.Execute(request);

说明:执行代码无报错/异常,说明已经生成成功。另外生成的文件信息存在注释(annotation)实体中

 

posted @ 2023-11-08 11:42  30号少年  阅读(16)  评论(0编辑  收藏  举报