Reputation: 1213
I've just finished writing a plugin for crm online, and am now running into a curious problem.
When I run the plugin through the debugger I get the expected results, but when I let the plugin run on its own it fails to run as expected.
In this plugin, I'm listening to the create event for new queueitems and I'm checking to see if the queueitm is an email. Everything up to this point is running as expected, however when after getting an email I check to see if the email has an attachment and here's when things start deviating. Through the debugger I can see the attachment file, but on its own, the plugin can't find the attachment. This is very odd to me because I can see the email in the queue and there's definitely an attachment there.
What would cause this to happen, why does it happen and is this a common problem?
Upvotes: 1
Views: 167
Reputation: 17552
Bit of guess.
There is a timing issue, when you debug and that timing issue isn't apparent because you have artificially slowed the application down.
I'm guessing your plugin is sync, and things are happening like this.
In Execution
In Debugging
Given that the email and email attachment are separate database tables this seems like a good shout, CRM may be making the two create calls separately.
Ways to test this theory
Thread.Sleep
into your code (no more than 2 minutes, a minute should be fine).If my theory turns out to be true, the best resolution is to probably find another way to register your plugin.
Upvotes: 2