This tip explains step-by-step how to use LotusScript to open an Internet Explorer browser as dialog box to transfer values between a Lotus Notes client and a Web-based application.
- Create a form.
- Go to Form Global Declaration and declare the following:
Dim Uidoc as NotesUidocument Dim IE as variant
- Create an Editable Field Name called "HTML."
- Create a button named "Open," and then copy the following script:
Dim Ws as New NotesUiWorkspace Set Uidoc= Ws.CurrentDocument Set IE=CreateObject("InternetExplorer.Application") IE.Height=450 IE.Width=550 IE.ToolBar=False IE.StatusBar=False IE.Resizable=False IE.Navigate "http://notes.net/46dom.nsf" IE.visible=True
- Create a button and name it "Populate":
Dim StrValue as string StrValue=IE.document.getElementByID("content-table").innerHTML IE.Quit call uidoc.FieldSetText("HTML",StrValue)
- Compose the form.
- Click on the "Open" button, and you'll find a "dialog box" opening the "notes.net" Web site.
- Go back to Lotus Notes, click on the "Populate" button, and you will see the HTML populated in the Lotus Notes field.
MEMBER FEEDBACK TO THIS TIP
This is a very interesting example. I've used the web retriever database to do this sort of thing in the past.
I had to play with the code and added a pause and retry loop in the "OPEN" script to perform the "POPULATE" function. (This could also be used as the code behind the POPULATE button)
'---- append to OPEN script 'Repeat until we give up or have success .. Const retry_count = 20 Const ElementID = "content-table" Dim aa%, Success% Dim StrValue As String aa = 0 Success = False On Error Goto KeepTrying GetElement: ' This fails if the page is not loaded yet StrValue=IE.document.getElementByID ( ElementID ).innerHTML ' We only get here if we retrieved the element .. Call uidoc.FieldSetText("HTML",StrValue) Success = True Goto TheEnd TryAgain: Sleep 1 aa = aa + 1 If (aa<retry_count) And (Not Success) Then Goto GetElement TheEnd: IE.Quit If Success Then Print "Success in " & aa & " second(s)" Else Beep Print |Failed: either the URL did not load in | & retry_count & | seconds or the element "| & ElementID & |" does not exist in the page.| End If Exit Sub KeepTrying: Resume TryAgain '---- end code ---
Do you have comments on this tip? Let us know.
Related information from SearchDomino.com:
This tip was submitted to the SearchDomino.com tip library by member Janardan P. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.