Can JavaScript be embedded in LotusScript?

I’m adding a web front end to a Notes database. The existing LotusScript includes the MessageBox function which is not web supported. When this LotusScript runs, I’d like to have it display a message in the browser. I’m already aware that this can be done with a Print statement - for example: Print “

This is a test

”

However, I’m interested in whether JavaScript can be embedded within the LotusScript so that a message is displayed in the browser either by using ‘window.status’ or ‘Alert’.

Thanks.

Subject: No, but…

you might want to explain why and when you want to show the message to gather some ideas on a work-around.

Subject: Can JavaScript be embedded in LotusScript?

My intent is to keep the existing LotusScript intact if possible while adding a web front end to the database. The current LotusScript includes the MessageBox function which is not web supported. If the MessageBox could be replaced with code that invokes the JavaScript ‘window.status’ or ‘alert’, this would be preferable to using ‘Print’ as the current window would not have to close when the message is displayed.

Thanks.

Subject: RE: Can JavaScript be embedded in LotusScript?

You can print JavaScript back to the web client, alright, but you can’t get it to work the same way as Messagebox. That is, your JS will need to be embedded in an HTML document, between tags, in order to run. That’s why you were asked to say what you were trying to accomplish (in total), rather than how you were hoping to accomplish it. Unless we know the effect you’re trying to achieve, we can’t make any suggestions as to how that effect may be acheived.

Subject: Can JavaScript be embedded in LotusScript?

Not sure if this is what you’re trying to accomplish, but you can use the LotusScript print statements (as you said) to print out the javascript for an alert. We used to use this to debug web apps all the time.

Is this what you had in mind?

Print “<script language=”“javascript”“>”

Print “alert(‘My alert message goes here’);”

Print “”

-SB

Subject: RE: Can JavaScript be embedded in LotusScript?

What you’ve suggested seems to be a good means of displaying an ‘Alert’. However, when the ‘Alert’ is displayed, the main window closes and a white window then is displayed. Ideally, the default view would be displayed instead.

The LotusScript with the ‘Alert’ code is in an agent that’s run by a form action. I’ve tried to display the default view after the ‘Alert’ as follows:

@Command([ToolsRunMacro]; “(AgentName)”);

@Command([FileSave]);

@Command([FileCloseWindow]);

@Command([OpenView];“(DefaultView)”)

I’ve also tried adding the following to the bottom of the LotusScript to display the default view after the ‘Alert’:

Dim evalResult As Variant

Const evalMacro$ = “@Command([OpenView];”“(DefaultView)”“)”

evalResult = Evaluate(evalMacro$, doc)

Neither of these options results in the default view being displayed after the ‘Alert’. If you have any ideas on this, please let me know.

Thanks.

Subject: RE: Can JavaScript be embedded in LotusScript?

I think you’re running into issues that involve the differences between how things work on the web, and how they work in the Notes client. The Notes client has a lot of places where you can “attach” code to options. You can simulate this in Javascript & Java… but it’s not easy.

The Javascript running with an agent in the Notes client will never get to a web-browser… A web client generally doesn’t see agent output. (There are times when you might use that…but it’s not “the norm”.)

You have a list of command that it appears you’re running in the same event from the Notes client { @Command([ToolsRunMacro];“(AgentName”));@Command etc… etc…

The way those are strung together appears to me to be a “QueryClose” event on a Form.

A form on the web ignores anything in the QueryClose event. Instead you have to write an agent to do all that processing and call it in the WebQueryClose event using @Command([ToolsRunMacro];“AgentName”)

This agent is run on the current document after you click on something with " @Command([FileSave]);@Command([FileCloseWindow])" for an action.

If you wanted to use any “popup” type things, you can have your Notes code write pass-through HTML, or insert a Javascript header with whatever Javascript routines you want, and call the “openwindow” function in Javascript.

There are some good articles in the archived NotesR5 discussion group on here that I know of. I found it an invaluable resource when learning to write web-enabled Domino apps back in 2000.

The single biggest thing to keep in mind for writing web-enabled apps is that you CANNOT use any front-end classes… they just don’t work. You have to stick with backend classes.

(I tend to prefer sticking to the back-end classes as much as I can anyhow… it makes it easier to move from platform to platform… and code portability rocks.)

Oh… back to answering your main question… you can’t really embed Javascript in LotusScript for a web-browser. (You technically can, but it’s a bad idea.) You should be looking to embed the Javascript routines you need into the form as a combination of the Javascript header, computed text, and often you also need to use fields.

You can interchange data between Javascript and Notes fields on a form pretty easily… and you can access values on parent window documents from child windows (i.e. write “pop up” windows that will modify data on the “main” window. Or pop up a message in a window before saving the document.)

Domino relies heavily on Javascript in rendering things for the web… so it interchanges well.

I’m sorry if this response isn’t organized well. It’s midnight!

Subject: RE: Can JavaScript be embedded in LotusScript?

Can you calculate the URL you want to go to within the script itself? Then you can just redirect your browser after the alert to go there… simplified example below - same script as before, but with another line added.

Print “<script language=”“javascript”“>”

Print “alert(‘hi’);”

Print “location.href=‘http://www.lotus.com’;” <----

Print “”