Quantcast
Viewing all articles
Browse latest Browse all 79901

Plugin Exception - create record

CRM Online, latest version.

I have a scenario where I need to record the fact that an exception has been thrown. In this instance it's to record that a dodgy email has attempted to be entered against the contact. I have the plugin running sync on both create and update of contact.

In my body I'm checking whether the email address matches:

try{
throw new Exception("<h2>Invalid Email Domain</h2>");
}
catch (Exception ex)
{
    Entity eRecord = new Entity("test_emailexclusionlog");
    eRecord["test_name"] = (string)targetEntity["emailaddress1"];
    eRecord["ownerid"] = new EntityReference("systemuser", context.UserId);
    tracer.Trace("create log record #2");
    service.Create(eRecord);
    throw new InvalidPluginExecutionException(ex.Message);
}


but the log record isn't being created.


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>