The key is to use double nested conditions:
//this will not work "call to 'next' should be done only once and unconditionally"
protected void
chooseLinesPackingSlip(boolean _append)
{
If
(true)
{
this.somethingElse(_append);
return;
}
next
chooseLinesPackingSlip(_append);
}
//this will work
protected void chooseLinesPackingSlip(boolean _append)
{
If (true)
{
if (true)
{
this.somethingElse(_append);
return;
}
}
next chooseLinesPackingSlip(_append);
}
Very interesting Hendy.
ReplyDeleteAs the documentation suggests: "Wrapper methods in an extension class must always call next, so that the next method in the chain and, finally, the original implementation are always called. This restriction helps guarantee that every method in the chain contributes to the result."
This might be suitable for prototyping, but you could encounter problems when this is combined with other extensions. So hopefully this won't break other extensions by you and others.
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/extensibility/method-wrapping-coc#wrapper-methods-must-always-call-next
- Chris Garty (Microsoft - F&O PM - Platform Extensibility)
Hi Chris, thanks for your comment.
DeleteI understand that requesting Microsoft to add the [Replaceable] attribute into the method is probably the best way to go forward instead of doing this