Sometimes the Domino engine causes you to do more work than normal by requiring or imposing restrictions to tasks. You can bypass the Domino engine with a LotusScript agent and get exactly what you want every time.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
These examples are meant to show what's possible and with how much code. They make use of an extensive class I've written to simplify the job -- but it's the concept that is important here.
Here's an example of an agent I use to open HTML documents that I store in my database. One agent opens any HTML document.
Dim Session As New NotesSession Dim db As NotesDatabase Dim Request As NotesDocument Dim HTMLView As NotesView Dim ScriptView As NotesView Dim HTMLDoc As NotesDocument Dim ScriptDoc As NotesDocument Dim WebPage As New Web Dim Index As Integer Dim HTML As String Dim Script As String Dim Title As String Dim URL As String Dim Parsed As Variant Set db = Session.CurrentDatabase Set HTMLView = db.GetView("HTML") Set ScriptView = db.GetView("Script") Parsed=WebPage.checkCGI("") 'Lets go get whatever was sent to use from the browser '============================== ================================ ================ === ' Go through all of the variables we got in the URL and take some action. ' This routine is only ready to process the URL, PAGE variable and the DOCTYPE Variable. ' PAGE opens a database stored HTML & Associated Script document ' URL opens whatever URL it is sent. ' DOCTYPE Opens the specified page in the Application you specified. It will currently supports WORD & EXCEL '================================= ================================== =========== === For Index = 1 To Ubound(Parsed) Select Case Ucase(Parsed(Index, 1)) Case "URL" URL = Mid$(Parsed(Index,2), 2, Len(Parsed(Index,2))-2) 'Strip the beginnign & End Quotes that had to be there Print "[" & URL & "]" 'Navigate directly to the URL specified (just put the complete URL in ) Exit Sub 'We're done here Case "PAGE" Title = WebPage.ParseReplace(Parsed (Index,2), "+", " ") 'Replace any HTML + characters with spaces ready for the view lookup. Set TITLE variable as our doc name Case "DOCTYPE" Select Case Ucase(Parsed(Index, 2)) Case "WORD" WebPage.Contenttype="WORD" 'Tell the WebClass that we're opening this page in MS Word Case "EXCEL" WebPage.Contenttype="Excel" 'Tell the WebClass that we're opening this page in Excel End Select End Select Next '================================= ================================ ============= === Set HTMLDoc = HTMLView. GetDocumentByKey(Title) 'Go Get the HTML Page Set ScriptDoc = ScriptView. GetDocumentByKey(Title) 'I name the script pages the same so go get that too If Not (ScriptDoc Is Nothing) Then Script = ScriptDoc.Script(0) 'If there was script, put it in a nice string variable End If HTML = HTMLDoc.HTML(0) 'Same goes for the HTML. You dont have to but I like to WebPage.Title = Title 'Set the Webpage title to the Name of the HTML doc I was told to get WebPage.Head = Script 'If there was some script or CSS, send it to the WebPage class for the page Call WebPage.StoreHTML(HTML) 'Send the HTML we got from the Document to the Webpage class Call WebPage.PrintHTML() 'Create the page and send it to the browser
Now, all the calls to the WebPage class are calls to a very large custom class that I've created entirely in LotusScript that packages everything very nicely for me and parses out all the data elements.
If you read through the comments, you'll notice that I can open any page in the database, open any URL from any other database or site and even launch Microsoft Word or Excel on the visitors machine and send them the file for the program formatted in HTML.
Such agents can be used as Brokers and to retrieve data from multiple records to form a single HTML page or to selectively retrieve Web safe data from databases not available on the Web. The agent runs on the agent signer's rights and the code decides what it will access and what it won't.
Another cool agent is one for my PayPal credit card transactions. Paypal sends me purchase details to which I need to respond. This is all done on the backend through HTTP post methods. Again, this uses my Web class to parse out the data for me, and read it from the Web without the need for a Notes form or view of any kind.
Sub Initialize Dim Session As New NotesSession Dim db As Notesdatabase Dim Doc As NotesDocument Dim Webpage As New Web Dim Index As Integer Dim field As String Dim html As String Dim Parsed As Variant Set db = session.currentdatabase Set Doc = New Notesdocument(db) Msgbox "IPN Initiated.............................. ........................................ ............................................................................... ............................................................................... ............................................................" Doc.Form="IPN" Webpage.ContentType = "POST" Parsed=WebPage.CheckCGI("") HTML=HTML+|<Form Method="Post" Action="http://www.sandbox.PayPal.com/cgi- bin/webscr">| For index = Lbound(Parsed) To Ubound(Parsed) Call Doc.AppendItemValue(Parsed(Index,1), Parsed(Index,2)) HTML=HTML+|<input type="hidden" name="| & Parsed(Index,1) & |" Value="| & Parsed(index,2) & |">"| Next HTML=HTML+|<input type="hidden" name="cmd" value="_notify-validate">| HTML=HTML+"</Form>" Call Webpage.storeHTML(HTML) Call Webpage.PrintHTML() Call Doc.save(True, True) End Sub
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member John Goodwin. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.