I'm a bit of a loss at a particular problem I'm having with a plugin I've made. The plugin is registered on the quotedetail entity (update & pre-operation). It's supposed to calculate the values for the tax fields and enter the values in the corresponding fields. However, the plugin is causing an infinite loop. Normally this is caused by saving the entity in the plugin code it's registered on, causing the plugin to trigger itself. But the problem is I'm not saving any entity, let alone the one where the plugin is registered on. The only time I use the Organization service is to retrieve data from CRM.
After testing this some more, I found out the infinite loop is in fact triggered the very moment the plugin calls OrganizationService.Retrieve, which fetches values from the parent quote. And sure enough, if I check the PluginExecutionContext.Depth in my code and set a return when it's more than 1, the plugin works fine. But there are times when it won't be set to 1, so I need to find out what's causing the problem. I don't understand how the Retrieve method can end up triggering a plugin. Any ideas?