Calling JavaScript from LotusScript

How can I call a JavaScript function from LotusScript?

I’ve tried adding a JavaScript library under ScriptLibraries (with “Use myLibraryName” added to the LotusScript), but I still get “Not a sub or function name” when attempting to save the LotusScript.

I also thought I could put the JavaScript in an agent, and call the agent from LotusScript, but it looks like agents cannot be JavaScript.

Subject: Calling JavaScript from LotusScript

USE won’t work here. Whenever you write things to a web browser from a LS agent, you use a print statement (this applies to html and js).

Sooo, you need to have your LotusScript agent Print the normal reference to the javascript library, making sure to escape quotation marks where needed so your format is correct. Then use additional Print statements in the LS agent to call the Javascript methods in the Library.

Now, outside all of this, what are you trying to do? What is your goal here? That’s always a good thing to state, as there may be a simpler method to do what you hope to accomplish.

Here is an example of a simple print statement to throw up a javascript alert

Print ||

Subject: RE: Calling JavaScript from LotusScript

dont forget …

Set doc = session.DocumentContext

if you are going to be generating HTML/JavaScript via LotusScript with the pront statement

Subject: RE: Calling JavaScript from LotusScript

Basically, we have an existing LotusScript agent that trys to identify and return a specific document. We have a separate JavaScript agent that performs advanced searches.

The idea here is that if the LotusScript agent fails to find its specific document, we want to pass the parameters to the JavaScript agent and provide the user with search results of “close matches.”

Subject: RE: Calling JavaScript from LotusScript

Do you mean a Java agent or Script library? There is no such thing as a Javascript Agent in Domino. There are no Notes/Domino related document methods in Javascript. Java and Javascript are two separate languages with a similar syntax and name. You can call a Java agent from a Lotusscript agent. For something like this, however, it seems like the better solution would be to modify either the LS or Java agent to perform both sets of searches. You will almost certainly get better performance that way, plus have only one set of code to maintain.

Subject: RE: Calling JavaScript from LotusScript

Sorry, I meant to say a JavaScript function – not agent. These functions are defined in a .js page in the database. There are no Java agents in this database. (I’m a Java programmer. If we were using Java here, there would be no problem.)

The things is, the existing LotusScript agent and the JavaScript function are called independently in other situations, so we need to leave these intact. It will be an unusual situation in which we want to call the JavaScript function from the LotusScript agent. A convoluted (but perhaps workable) approach would be to code the $$ReturnGeneralError page to call the JavaScript function onload, or redirect to a page that calls the JavaScript.