I'm facing a really annoying error on my Delete plugin on the salesorderdetail Entity. As follows I have a post-create plugin registerd on the entity which creates another salesorderdetail record (a support line to the product). Now I have a Delete plugin which should fire when I delete the intiial salesorderdetail record. To remove confusion A creates B, when A is deleted (Delete plugin fires) automatically delete B. My logic and plugin works for the opportunity product lines and qoute product lines. I'm getting an error "The detail cannot be updated because the parent is not editable", when I try to delete A (the intial salesorderdetail). Now my question is how can I avoid the error? I would really much appreciate if someone could help me out here. Thanks in advance.
2 Answers
1
votes
Is it possible that, with your current logic, you are using two differents entities ?
One possible things is that, as you work now with two records from the same entity, the delete plugin triggers twice and could throw an exception at the second execution.
To avoid that, simply add this at the start of your execute method :
if(pluginExecutionContext.Depth > 1)
return;
Your plugin will be forbid to be trigger by another plugin or by itself.
Regards,
Kévin