FAQ: How to hook to function execution in the Service Engine over the API?
COM: RtFunctions contains a new event (PreExecuteFunction) which gets fired before a function is executed. This event handler contains a parameter which is a temporary copy of the function which is about to be executed.
ADDIN: An identical event handler is also available for Addins (FunctionExecuting) in IFunctionCollection. You can find more information in
this online documentation topic.