Using system.* inside a custom function?

Inductive have confirmed that this is a bug (ticket #44974).

Custom functions on windows cannot access project/system or import anything. The workaround is to move the custom function to a component. The best option is to move them to the Root Container.

I would strongly advise against using multiple invokeLater calls to fix this, as this is likely to be unreliable.