Skip to main content
This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

developerWorks

  

PreviousPrevious NextNext

RE: Run Agent from Javascript
Willy Lorenzo 22.Oct.07 12:18 PM Lotus Notes
Domino Designer 6.5.5 All Platforms



Here is the method that I use to accomplish this. It’s not difficult but you need to pay attention to the details. In essence you are taking a single process and breaking it up amongst several systems, each one working independently. The messaging between systems is the key to controlling what’s happening and maintaining the unity of the process.

This process uses an old concept called reentrant programming. This concept is used in mainframe programming. It was the method use to get a mainframe of 30 years ago to handle 1000 users. Basically, you run your program and present some interface to a user (usually a green terminal screen.) Then your program ends...completely. It may even get tossed from memory. When the user presses Enter the terminal starts your program again. At that point you figure out where you left off and continue processing. Since users spend more time thinking and typing than the computer spends processing, you can have a thousand people working while the mainframe is only processing for a few users at any given moment.

We’re going to use this concept as a method of switching between languages.

First you create a field on the form that you’ll use to transfer instructions from one language to another. I usually call it NextStep. I usually also have an ErrorMessage field to go with that. Create other fields as needed to transferring data between languages. These can be computed fields equal to themselves.

Next you create a button at the bottom of your form with the formula for running the agent. DO NOT HIDE THE BUTTON. Rather, set the HTML tag Style to display=none. Also set the HTML Name. You’ll reference this later in JavaScript. In this example the HTML Name is WebProcesses.
Enter a formula such as:
@Command( [RunAgent] ; "web_processes" )

Next you create some onload code in your form to process the response from your agent. So in the onload of the form you’ll have something like:

var NextStep = thisform.NextStep.value
if (NextStep != "" ) {
thisform.NextStep.value = "" //reset NextStep as quickly as possible. Don't let it linger.
switch (NextStep) {

//Close process
case "UpdateNotes_CloseForm": //Closes the dialog and returns data.
window.opener.close()
window.close()
break

//Messages
case "Error":
alert( thisform.ErrorMessage.value )
break

//Refresh
case "Refresh":
thisform.ViewRefreshFields.click()
break
}
}


Finally, write the JavaScript for your hotspot.

thisform.NextStep.value = "UpdateNotes_SaveNote"
thisform.WebProcesses.click()


Okay...now you’re ready to process this. Here’s how it works. First you click your hotspot to execute the JavaScript. The JavaScript sets the NextStep field as an instruction to the agent. Then it clicks the WebProcesses button. That’s it. The JavaScript is over.

Next the formula in the button takes over and executes the agent. The formula hangs and waits for the agent to finish.

In your LotusScript agent use NotesSession.DocumentContext to get the document and check the NextStep field. Have a Select statement to choose which sub gets executed based on the NetStep value.

NextStep = docCurrent.NextStep(0)
docCurrent.NextStep = "" 'Reset immediately to prevent this process from running again if there's a failure.

Select Case NextStep
Case "WebQueryOpen"
Call WebQueryOpen

Case "UpdateStatus_QueryClose"
Call UpdateStatus_QueryClose

Case "UpdateNotes_SaveNote"
Call UpdateNotes_SaveNote

End Select


Execute your code. When the code need to break for a message, you set your NestStep field to the appropriate value to be processed by the form onload. For example, you might have a validation failure and set it to “ValidationError” and you might set the ErrorMessage field to “Please enter a recipient.” Then you simply end your agent.

When your agent ends, your form will reload. This happens automatically whenever a button on the form is clicked and ends processing. When it reloads the onload event will run. In the onload you simply check the NextStep field and do what’s necessary based on its contents. Refer to the JavaScript Switch statement above.

Now that you’re back in JavaScript you can click buttons and start the process all over again. In this way you can loop between JavaScript, formula, and LotusScript to accomplish anything you need to.





Run Agent from Javascript (David Inglis 22.Oct.07)
. . RE: Run Agent from Javascript (Diane Mocny 22.Oct.07)
. . . . RE: Run Agent from Javascript (David Inglis 22.Oct.07)
. . . . . . RE: Run Agent from Javascript (Diane Mocny 22.Oct.07)
. . . . . . . . RE: Run Agent from Javascript (M. Vereecken 22.Oct.07)
. . . . . . RE: Run Agent from Javascript (M. Vereecken 22.Oct.07)
. . RE: Run Agent from Javascript (Willy Lorenzo 22.Oct.07)
. . . . RE: Run Agent from Javascript (M. Vereecken 23.Oct.07)
. . . . . . RE: Run Agent from Javascript (Willy Lorenzo 23.Oct.07)
. . . . . . . . RE: Run Agent from Javascript (Stan Rogers 23.Oct.07)
. . . . . . . . . . RE: Run Agent from Javascript (Willy Lorenzo 24.Oct.07)
. . . . . . . . . . . . RE: Run Agent from Javascript (Stan Rogers 24.Oct.07)
. . . . . . . . . . . . . . RE: Run Agent from Javascript (Willy Lorenzo 24.Oct.07)
. . . . . . . . . . . . . . . . RE: Run Agent from Javascript (Stan Rogers 25.Oct.07)
. . . . . . . . . . . . . . . . . . RE: Run Agent from Javascript (Willy Lorenzo 25.Oct.07)
. . . . . . . . . . . . . . . . . . . . RE: Run Agent from Javascript (Stan Rogers 25.Oct.07)
. . . . . . . . . . . . . . . . . . . . . . RE: Run Agent from Javascript (Willy Lorenzo 25.Oct.07)
. . . . . . . . RE: Run Agent from Javascript (M. Vereecken 23.Oct.07)


Document Options






  Document options
Print this pagePrint this page

Search this forum

Forum views and search


  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Author
Category
Platform
Release
Advanced search

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

Resources

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds

Wikis

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums


 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite