使用 Dynamics 365 for Customer Engagement 中的文档模板将 Customer Engagement 数据导出为 Excel 或 Word 文件,这些文件可用作模板,以生成包含标准化和 up-to日期 Customer Engagement 数据的 Excel 或 Word 文档,以便进行分析和报告。 使用文档模板可确保为您的公司和客户提供一致且标准的数据表示。 详细信息: 使用模板
使用 Web 客户端创建文档模板后,您可以通过编程方式将模板文件(.xlsx 或 . docx)上载到 Customer Engagement 实例,更新与文档模板记录关联的名称或模板文件,检索文档模板记录,并删除文档模板记录。 使用实体 DocumentTemplate
上传和管理组织拥有的文档模板,使用 PersonalDocumentTemplate
实体上传和管理用户拥有的文档模板或个人文档模板。 您可以将个人文档模板共享或分配给其他用户。
要上传文档模板,请以 base-64 编码的字符串形式指定文档的路径、名称、文档类型(Excel 或 Word)和内容(要上传的文件)。 以下代码示例演示了如何上传组织拥有的 Excel 模板。 在上传模板之前,您必须已使用 Web 客户端创建 Excel 模板文件。
string filePath = @"C:\ActiveAccounts.xlsx";
DocumentTemplate myTemplate = new DocumentTemplate
{
Name = "Sample Excel Document Template";
DocumentType = new OptionSetValue(1); // For uploading an Excel template.
Content = Convert.ToBase64String(File.ReadAllBytes
(Path.Combine(Directory.GetCurrentDirectory(), filePath)))
};
_templateID = _serviceProxy.Create(myTemplate);
Console.WriteLine("Uploaded template: '{0}'.", myTemplate.Name);
如果要上传 Word 模板文件,请在变量中 filePath
指定 Word 模板文件的路径,然后更改 DocumentType
参数,如以下示例所示。
DocumentType = new OptionSetValue(2); // For uploading a Word template.
上传模板后,请将其激活,以便将其用于生成文档。 使用消息 SetStateRequest 激活您刚刚创建的实体实例。