Xpages PostNewDocument

I have an XPage for which i have created a SSJS function for; there are 2 instances where i use this function:- PostNewDocument

  • Form button (on new and existing documents)

I have tried putting the function into a script library and presenting the resource to the xpage; this works fine for the button but not the postnewdoc event. I assume that resources are not loaded until after the document events.

Is there another way i have present this function once to the xpage and then be called by the PostNewDocument and button?

It turns out that i was doing something an you are able to use script library as a resource on the page.