Jorey
Jorey

Reputation: 61

Reference/call SSJS library/function in another database

In XPages, is it possible to call a function in a SSJS library in another database? I'm trying to include a script resource in my custom control that points to a SSJS library in another db. (I'm trying to avoid duplicating the lib by copying it over.) Per this question, I determined the full path to the library by going to the Package Explorer view.

<xp:this.resources>
    <xp:script src="picker.nsf/code/scriptlibraries/mylib.jss" clientSide="false" />
</xp:this.resources>

I tried prefixing the path both with and without a \ or / and also propercasing the path, but I continue to get the following runtime error:

Error while executing JavaScript action expression JavaScript library

/picker.nsf/code/scriptlibraries/mylib.jss is not available

I also tried putting copies of picker.nsf in the root (Domino data folder) and in the same subfolder as the primary db but that didn't work.

I think the source question above refers to a .js file that was attached in the files area rather than a code library so it might not apply. Any ideas?

Upvotes: 0

Views: 58

Answers (1)

Fredrik Norling
Fredrik Norling

Reputation: 3484

You need to separate the thinking of serverside js and client side js. Serverside javascript is not "real" javascript like in Node.js, it does only work in the context of a single database and is at runtime running inside the java engine. There might be some OSGI functionality that can inject the code from another database but nothing that is official supported.

Client side javascript is running in the client browser and can access everything that the client browser can access.

Upvotes: 3

Related Questions