在Dynamics CRM 2011中以电子邮件形式自动填充字段

时间:2011-06-27 11:30:22

标签: dynamics-crm dynamics-crm-2011

想象一下,您想要向案例添加电子邮件。将打开电子邮件表单,并使用案例的客户帐户自动填充“收件人”字段。

我想更改行为,以便使用相关案例的自定义属性自动填充“收件人”的内容。

我的第一种方法是为表单的OnLoad事件注册一个JavaScript,让脚本更改字段。这可行,但我想知道是否有更聪明的方法来实现这一目标。已经存在一些填充“To”字段的逻辑。 是否可以配置此现有功能

任何提示都表示赞赏。

3 个答案:

答案 0 :(得分:2)

我不相信这个特定场景可以比你已经解决的方式更有效地完成。我建议查看数据映射(在实体的自定义中弹出关系时的左导航项,与此Dynamics CRM 4.0文章http://www.dynamicscare.com/blog/index.php/modifying-mapping-behavior-between-parent-child-records-in-microsoft-dynamics-crm/中讨论的概念相同),但它似乎不是适用于这种关系。

答案 1 :(得分:1)

这可能会对您有所帮助:

           DataService.EntityReference toEntityRef = new DataService.EntityReference();
            toEntityRef.LogicalName = "contact";
            toEntityRef.Id = Guid.Parse(to_id);
            Entity toParty = new Entity();
            toParty["partyid"] = toEntityRef;
            toParty.LogicalName = "activityparty";
            Entity emailEntity = new Entity();
            emailEntity.LogicalName = "email";
            EntityCollection toCollection = new EntityCollection();
            toCollection.Entities = new ObservableCollection<Entity>();
            toCollection.Entities.Add(toParty);
            emailEntity["to"] = toCollection;
           IOrganizationService soapService = ServerUtility.GetSoapService();
           IAsyncResult res = soapService.BeginCreate(emailEntity, OnCreateComplete, soapService);

回拨方法:

    private void OnCreateComplete(IAsyncResult result)
    {                 
             Guid emailId = (IOrganizationService)result.AsyncState).EndCreate(result);
    }

答案 2 :(得分:0)

另一种方法是替换功能区中的添加电子邮件按钮,以便调用自定义JavaScript函数。此功能可以使用window.open打开邮件窗口,并按setting the extraqs parameter初始化 To:字段,为即将创建的电子邮件配置ActivityParty。这可以通过设置:

来完成
  • partyid到允许实体的实例的ID
  • partyname到实体实例的名称
  • partytype至2(对于recipent字段,请参阅here for details

但是extraqs参数是有限的:您只能设置一个接收器而不能设置其他字段(来自,cc,bcc,...)。此外,更换按钮会绕过内置功能,这可能会在将来的版本中发生变化,

所以我更喜欢处理表单的OnLoad事件。

相关问题