Dynamics CRM 2011 - creating an object blog through a plugin

Problem: We use the CRM plugin for Outlook to automatically log into our support emails, but internal emails between employees (some of which contain confidential information) are also recorded.

Ideal solution: I am trying to write a pre-event (message "create a letter") to block the automatic maintenance of internal letters, but (apparently) the only way to stop the message from being executed is to throw an exception at the stage of the preliminary event, but this always causes an error message to be displayed in Outlook (which we obviously don’t have). According to the documentation, only "InvalidPluginExecutionExeception" should show messages to the user, but this is not so, since all exceptions lead to an error message in Outlook for users.

Potential solution: There is also a “CheckPromoteEmail” message that (according to the documentation) determines whether to promote the email in CRM (I assume that “promotion in CRM” means “make a mailbox for storage in CRM”), but I don’t could find nothing in a context that would let me tell CRM not to promote email. Is there some kind of flag buried in the context that I can set, or in some way in order to invlaidate the email so that my own CRM logic decides not to store it?

Workaround: The only other solution I know of (mentioned here ) is to simply clear the subject and contents of the email after it was created, but I would rather prevent email from being created in the first place than editing or deleting it after that how time and resources were wasted creating an email.

Is there any way to stop the operation from the plugin? Or from anywhere? If this does not happen, does anyone know why Microsoft did not provide this feature? They already have rollback functionality from swap under the hood in case of a malfunction, why don't they give me a way to trigger a rollback?

Here is my code in case it helps in answering my question:

public class InternalEmailFilter : IPlugin { void IPlugin.Execute(IServiceProvider serviceProvider) { IPluginExecutionContext _context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); Entity e = (Entity)_context.InputParameters["Target"]; bool shouldStore = ShouldStoreInCRM(e); if (shouldStore == false) { throw new Exception(); //attempting to stop the operation without an InvalidPluginExecutionException, but still results in error message to user } } protected bool ShouldStoreInCRM(Entity e) { List<Entity> parties = new List<Entity>(); var atttributes = e.Attributes; if (atttributes.ContainsKey("to") == true) parties.AddRange((atttributes["to"] as EntityCollection).Entities); if (atttributes.ContainsKey("from") == true) parties.AddRange((atttributes["from"] as EntityCollection).Entities); if (atttributes.ContainsKey("cc") == true) parties.AddRange((atttributes["cc"] as EntityCollection).Entities); if (atttributes.ContainsKey("bcc") == true) parties.AddRange((atttributes["bcc"] as EntityCollection).Entities); foreach (Entity p in parties) { if (p.LogicalName == "activityparty" && p.Attributes.ContainsKey("addressused") == true && p.Attributes["addressused"] != null) { if (p.Attributes["addressused"].ToString().ToLower().Contains("@ourdomain.com") == false) { return true; //someone connected in the email is not an employee, store the email } } } return false; //everyone was an employee, do not store } } 
+4
source share
3 answers

After a lot of blood, sweat and tears, I finally figured out how to do this:

You should use the async post-event plugin in the "Create Email" message to remove email from the database using CRMService after creating it. It must be asynchronous because you need to wait for CRM to complete the creation and release the object before you can delete it. Otherwise, the process freezes.

Any of these solutions would be better, but for reference, you cannot:

  • Throw an exception in the pre-header to cancel the create / promote email operation without showing the user an error message or without destroying their Outlook. Although only InvlaidPluginExectuionExecption should show a message to the user, all exceptions display error messages to users.
  • block an email ad campaign for CRM. The preliminary event of the CheckPromoteEmail message (surprisingly) does not provide any information about the message being potentially promoted (therefore there is no data to use to decide whether to promote the message), and there is nothing that could say that CRM will not promote it message. And, if you use pre / post-event and try to use the Output parameters and change the ShouldPromote flag, it does nothing.
  • Clear the contents of the body of the email before creating an entity for it - any changes you make to the contents of the body in the pre-event do not remain in the execution context and are lost when the main operation begins.

Maddening.

+7
source

Sorry, the workaround is your only option. The only way to stop the operation through the plugin is to throw an exception. Why did Microsoft do this? I guess they didn’t want the plugins to fail.

As for the workaround, you must clear the object and body before they enter the database, clearing them in your plugin before the events, and then clear the record itself in the asynchronous plugin after the event. Thus, confidential information does not fall into any audit logs.

Finally, look at DeliverPromoteEmail instead of CreateEmail . DeliverPromoteEmail is what Outlook uses to create monitored emails. That way, you could create emails in the CRM user interface that don't run this plugin (if necessary).

edit CheckPromoteEmail only considers the tracking token in the subject (and / or MessageID in the email header) to decide whether to track the email, so it will not be useful either.

+2
source

You have an option in your personal settings, where you can track all emails, email replies to CRM emails (already tracked emails), emails from records (accounts, etc.) and emails from records, which includes email.

0
source

All Articles