Create Email with a workflow in MS Dynamics Crm 2011 and dynamically fill the “To” field

十年热恋 提交于 2019-12-08 02:11:05

问题


I'm working on Ms Dynamics Crm 2011 development and I encountered following problem. My situation:

I want to be able to automatically send an Email after a change on a specific status field on a record of the Entity "MyEntity". "MyEntity" has an Email-field. I try to create a workflow which sends an Email to the Email-field address of the "MyEntity" record after the status has been changed. My problem is that I can't add in the Email Creation workflow to the "To" field this "MyEntity" Email-field adress. I need to somehow specify in the workflow to dynamically add the "To" field, the relating Email address from the specific "MyEntity". Is that possible? Is there a workaround for that? It could be done with a plugin I guess, but by now I'm trying to avoid the plugin solution.

Thanks in advance

John


回答1:


Yes, you should be able to. First go to Solutions, bring up your entity, go to Fields, bring up your e-mail field and ensure the Format is e-mail. Publish.

Work around: If you have more than 1 e-mail Format text field, change the others temporarily (to text from e-mail) and Publish. Otherwise, the next step is ambiguous and we don't have control over which field CRM sets up as the email to use when this entity is used for e-mail.

In the solution frame, select your entity node in the tree. Under Communication and Collaboration, check the box 'Sending e-mail (If an e-mail field does not exist, one will be created).' Save/Publish.

Fix the work around above if you had more than 1 e-mail format text field. Change them back to e-mail. Publish.

In Workflow, select your To Field. Under the Send e-mail step, select 'Set Properties.' Select the 'To' field. In the form assistant you should not be able to select your entity. NOTE: You will bind to the 'Key' field and NOT to the particular e-mail field.

This only works for a single e-mail field on your custom entity. There is no way to use a text field as an address in a CRM 'to' field.




回答2:


Unfortunately you cannot.

Out of the box the To field in an email accepts only

  • Account
  • Contact
  • Facility/Equipment
  • Lead
  • Queue
  • User

So in order to achieve the goal , you will have to write a custom workflow activity (optional : taking the custom text field in your input parameter )and refer it in your workflow or develop a plug-in.

Sample code for Plugin:

SendEmailRequest req = new SendEmailRequest();
req.EmailId = emailId;//ID of created mail
req.TrackingToken = "";
req.IssueSend = true;

For more information check this post Crm 2011 :Workflow - Sending email problem



来源:https://stackoverflow.com/questions/8940170/create-email-with-a-workflow-in-ms-dynamics-crm-2011-and-dynamically-fill-the-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!