How to set the Function in Flow or Globally

Hi, I am create the user-defined function into the function node; This function how to set to be flow or globally;I am try to used this function anywhere flow in to number of times; please guide me...

Create a subflow instead.

https://nodered.org/docs/user-guide/editor/workspace/subflows
Subflows : Node-RED

@Steve-Mcl related question from my side, something I was wondering the other night. Say you have some code stashed in a function node, 1 input, 1 output with a commonly occurring kind of handling. Are there better solutions than either setting up that single function node as subflow, or writing a custom node to do it as to not clutter the subflows too much?

I have in the past stored function object(s) in flow/global but that means mostly using function nodes to access them.

No Biggie but not exactly the "node-red way" (imo).

You could of course make a multifunctional subflow and use properties of msg for parameters and msg.topic as the function name.
Just be sure to use the self documenting features of the subnode to remind you how it works.

I tend to write a custom node only when additional libraries are required and/or many functions that would clutter subflow.