首页 > 解决方案 > 使用插件检索电子邮件模板

问题描述

我想通过模板的 Guid 检索电子邮件标题。有什么办法可以拿到头衔吗?

这是我的代码。我也在过滤模板。

public static void TemplateLogic(IOrganizationService service, string selected_option)
{
    var queryBuildInTemplates = new QueryExpression
            {
                EntityName = "template",
                ColumnSet = new ColumnSet("templateid", "templatetypecode"),
                Criteria = new FilterExpression()
            };

            queryBuildInTemplates.Criteria.AddCondition("templatetypecode",
             ConditionOperator.Equal, "contact");
            EntityCollection templateEntityCollection = service.RetrieveMultiple(queryBuildInTemplates);
}

标签: c#pluginsdynamics-crmcrm

解决方案


在上面的代码中要查询的属性列表中添加“ title ”。ColumnSet

ColumnSet = new ColumnSet("templateid", "templatetypecode", "title"),

您的代码基于“联系人templatetypecode”的值进行过滤,这就是它使用方法的原因。service.RetrieveMultiple

如果您知道记录 id guid,即 ie templateid,那么这是一个不同的调用。

Entity template = service.Retrieve("template", templateId, new ColumnSet(true));

new ColumnSet(true)将查询所有属性。


推荐阅读