Adding cases to switch statement via extension

I am adding an extension class to a standard class. I am trying to add more cases to a switch case statement in a existing method of a calss. How can i do this in D365?

protected void validateSourceLine(Common _sourceLine)

case tableNum(SalesLine) :
case tableNum(SalesQuotationLine) :
case tableNum(SalesBasketLine) :
case tableNum(SalesQuotationBasketLine) :
case tableNum(PurchLine) :
case tableNum(ProdTable) :

//new cases →
case tableNum(BOMVersion) :
case tableNum(ForecastSales) :
// new cases ←

throw error(Error::wrongUseOfFunction(funcName()));

The answer is simple: it’s impossible. Adding code in a middle of a method would require changing is code, which isn’t an extension.

You have two options:

  1. Either you’ll find a way how to implement the behavior you need without this particular change.
  2. Or you’ll ask the owner of the code to make it extensible. If it’s Microsoft, it means logging an extensibility request on LCS.

By the way, please use Insert > Insert Code to paste source code; it makes it easier to read. Also, please pay more attention to what you use as a title (I’ve already fix it).

Thanks for your reply.