« Domino.Doc Project Manager Position for Large Media Company in Washington, DC Area | Main| June 8th DC Lotus User Group Meeting »

Calling Lotusscript from Javascript for OpenLog

QuickImage Category


Much has been said recently regarding Julian Robichaux's excellent error and event logging tool Openlog.  I gave a brief overview of it at last night's DC Lotus User Group meeting, showing just how easy it is to implement.  It was even featured on a recent Taking Notes podcast by Julian and Buce Elgort.  

Since I deployed OpenLog on a recent project working with Domino Document Manager, I had to figure out how to log events that could only be triggered by javascript.  In this case, the launch of a file attachment directly from a view meant that I wasn't launching a *Notes* document, and therefore could not simply use a WebQueryOpen agent. The problem is that OpenLog provides calls from Lotusscript and Java, but not Javascript.  At least not directly.  Well, there are a number of straightforward posts in the Notes Fora about getting javascript to trigger a Lotusscript agent, but I discovered a few gotchas along the way to implementing them.  So I thought I'd encapsulate my lessons learned here.

Since I wanted to record the user action of viewing a file from within the web interface of Domino Document Manager, I needed to hack the appropriate $$ViewTemplate form in the file cabinet template.  Here's what I did:

Step 1: Write a simple Lotusscript agent to call standard LogEvent code provided by OpenLog.  We'll call the agent "RecordDocView" and give it an Agent List trigger.

Step 2:  Create a hotspot button as shown here, which contains the @Command code to trigger the agent.  The important attributes of this button are the HTML properties, which should be set up like I've done here.  Giving the Name attribute a value will allow us to programmatically "click" the button with Javascript.  Setting the Style attribute is how you make the button invisible, but still available for clicking.  It doesn't seem to matter if you set the Id attribute instead of the Name - it works the same either way.

A picture named M2

Step 3: Here's where I found a big gotcha.  On the Paragraph Style tab of the hotspot properties, make sure "[None]" is selected as shown here.  If nothing is selected, javascript will not be able to "see" it and you will bang your head on the table for hours trying to figure out why.

A picture named M2

Step 4: Drop the following bit of Javascript within whatever function is being triggered by the user action:

document.forms[0].RecordDocView.click();

This code triggers the button, which triggers the Lotusscript Agent, and voila, you have recorded a javascript event in OpenLog.  In this case, the code was put at the end of the "DoLaunch" function, for those of you interested in doing this for Domino.Doc specifically.  

Comments

1 - Kevin -

That's fantastic! I'm about to link to this entry from the OpenLog project page, to make people aware of this technique. Awesome...

Thanks so much for doing the presentation at the user group meeting, and being an evangelist. Hopefully we got a few converts out of it.


I told Jack Dausman that I was going to try to make it to one of the DC user group meetings sometime. I'll let you know when I can, so I can give you some OpenNTF paraphanalia or something.

- Julian

2 - Hello Urs! Nice to see how far this blog can reach around the world.<br><br>As for your question, I used "visibility:hidden" because some of the examples I used to figure out the technique had used it, and it works. If display:none works as well, and does so across browsers and OSes, I guess you could just as easily use that instead. There's always more than one way to solve a problem.

3 - The main difference between visibility and display properties in CSS is that if an element is hidden with the visibility property, it is not visible in the browser. This means, it will not be accessible by JS because its not part of the DOM. If display property is used, the element is in the DOM but not shown to the user. It is accessible by JS. I think if one uses display, step 3 is not necessary.

4 - I'm just curious about the visibility:hidden.
Why don't you use just a display:none;

greetings from switzerland
urs

Your Host

KevinPettitt.jpg
Kevin Pettitt View Kevin Pettitt's profile on LinkedIn

Tools I Use

Idea Jam

Subscribe to This Blog

 Full Posts  Comments

MyYahoo
netvibes Add to Netvibes

Contact

Hosted by

OpenNTF

Disclaimer

This site is in no way affiliated, endorsed, sanctioned, supported, nor blessed by Lotus Software nor IBM Corporation, nor any of my past or future clients (although they are welcome to do so). The opinions, theories, facts, etc. presented here are my own and in no way represent any official pronouncement by me on behalf of any other entity.

© 2005-2017 Kevin Pettitt - all rights reserved as listed below.

Creative Commons License
Unless otherwise labeled by its originating author, the content found on this site is made available under the terms of an Attribution / NonCommercial / ShareAlike