1
votes

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

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

0
votes

I believe that your salesorder record needs to be in a status of "new" (statuscode == 1) for you to edit it.

Consequently your delete plugin may need to set salesorder status to "new", delete the required orderdetail records and then set it back to the original value.