2011-06-27 46 views
2

想象一下,您想要将电子邮件添加到案例中。电子邮件表格打开,“收件人”字段将自动填入案件的客户帐户。在Dynamics CRM 2011中以电子邮件形式自动填充字段

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

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

任何提示表示赞赏。

+0

@downvoter:什么是错的问题吗? – Stephan

回答

0

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

  • partyid到允许实体的实例
  • partyname的ID到实体实例
  • partytype 2的名称(则收件人现场,看到here for details

extraqs参数有限:您只能设置一个接收器,而不能设置其他字段(来自cc,bcc,...)。此外,更换按钮将绕过内置功能,这可能会在未来版本中更改,因此我更喜欢处理表单的OnLoad事件。

+0

Touche,这将是另一种方式来做到这一点。替换按钮或覆盖其命令定义。如果你期望改变onLad肯定是一条路。 – GotDibbs

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); 
    } 
相关问题