Replaceable methods

Chain of command enables wrapping of methods – but you must call next. This ensure the "chain" is not broken, and everyone wrapping the method will indeed be called.

However, sometimes it makes sense to break the chain. Here are some examples where this could be useful:

  • In lookup methods. The base implementation will open a lookup dialog, anyone wrapping will (likely) also open a dialog. Yet the user only expects one lookup.
  • In methods with complex SQL operations. As of now; there are select statements (including delete_from, update_recordset, insert_recordset) we cannot make extensible. One way to work around the limitation is to move the statement to a dedicated method, and make the method replaceable.
  • In conversion methods. Here you can conditionally call next, to skip the base conversion, if your logic can handle the conversion.

In Platform Update 11 – we can now decorate methods with the [Replaceable] attribute. This will relax the compiler, so it doesn't look for the next keyword. Logically, this means that when wrapping a Replaceable method, there is no guarantee that your logic will fire. Someone else might be replacing the method, and breaking the chain.

The author of the code is still in control of which methods are replaceable.

My dear "partner in crime" Vanya Kashperuk has written a great post about the new capability here:



Comments (2)

  1. Giridhar K says:

    Hi Michael,

    Thank you very much for the information. I have a situation where i need to pass extra information for a standard method. Previously we used to send them as a new parameter to the method. But now how do we handle such cases. In my sample i need to pass extra information to insert/update methods and use the information inside it.
    Can you let me know how to handle such scenarios in extensions?

    I feel this very common issue for all.
    Thank you very much in advance.

Skip to main content