Friday, May 16, 2008

New XSL for Form and Database

I've added two new stylesheets: dsDatabase.xsl and dsSingleFormSubformOrPage.xsl (see sidebar for links)

dsDatabase.xsl provides a short synopsis of a database while dsSingleFormSubformOrPage.xsl provides considerably more detail. Both make use of the ds.css stylesheet cribbed from Christian Gorni's Synopsis2.css (if you're using Firefox use the 'Open in IE tab' to see the correct .css format; the page links won't work correctly but they do when you run thinks through DXL Transfomer). One drawback, the Form stylesheet is only meant to be used with one form at a time; it will produce output for all forms if more than one is selected but the page links will only work for the first form.

Some features of the new Form synopsis are:

  • List of all properties not having a value of 'false'
  • List of Shared Fields, Actions and Subforms (with details if available)
  • An indexed table of Fields
  • Hide-when Properties and Formulas
  • Keyword field types (radiobutton, dialoglist, etc) with choices/formula
  • Formatted Notes Names
  • Formatted formula/script code (long lines are wrapped)

I've also updated REPORT-DesignElements.xsl with the new format templates.

Working with the DXL Transformer utility is a bit of a pain as it provides no debug information; the transform either works or fails. Thankfully I found Cooktop, this free XML editor allows you to load a stylesheet and and and .xml file so I was able to export an xml for a form, load it up and use it in Cooktop for testing.

On to Views.

Friday, May 09, 2008

Revised XSLT Design Synopsis Template

Worked out most of the bugs (I think). The field hide-whens are now showing up where they belong, with the fields, and the code section is limited to the 'form' , 'view' or 'actionbar' and not all the code in the form, view, etc.

It's still pretty rough and does not pick up all the attribute values for each entity so I'll probably keep playing with templates; developing individual templates for each design element.

I've added a 'DXL Templates' list on the left with links to what I've done so far.

Sunday, April 27, 2008

XSLT Template for Design Elements

Awhile back Andre Guirard promised a nice umbrella to anyone who would take a crack at creating a stylesheet that could be run through DXL Transformer and produce something similar to the Design Synopsis. I haven't played with XSLT in a few years but had some extra time this week and decided to give it a try.

First, I poked around on notes.net to see if anyone else had already done something similar; I found a 2005 post by Joseph P White that I used as a starting point. I created two stylesheets REPORT-ListDesignElements.xsl and REPORT-DesignElements.xsl. The first simply lists all design elements in the database (in DXL Transformer, you need to select all elements for this to work correctly). The second will list details on one or more selected elements: Forms, Subforms, Agents, Script Libraries, etc.

Output Examples:
Personal Journal Design Elements
Personal Journal Form
Personal Journal View
Personal Journal Script Library

To use the stylesheets, just save them to your notes\data\xsl directory; open a database in Designer and fire up Tools->DXL Utilities->DXL Transformer, select one or more design elements and the REPORT-DesignElement.xsl stylesheet.

If you don't see DXL Utilities under Tools, edit your current location document and change your browser to Internet Explorer (I hope they've fixed this in Notes 8 so it will work with FireFox).

I've commented the .xsl documents so hopefully modifying them to suit your own needs won't be an onerous task. If you improve on them please share :)

Edit: Looks like this is not quite ready for prime time, the FIELD code for the HIDE-WHEN does not show up in the field section; same for the CLICK values of buttons and hotspots. Needs some re-engineering.

Thursday, April 03, 2008

DialogBox Behaviour

A dialogbox contained a checkbox option whose value was not being returned if the user closed the dialogbox by hitting Esc or clicking the 'x' in the window frame instead of using the dialog OK button. The fix was a simple one: added @Command([RefreshParentNote]) to the QueryClose event of the dialog form and the checkbox data was correctly passed to the underlying document. The command has been around since Notes 5 but I wasn't aware it existed (or if I was, I'd totally forgotten about it).


The command (also available through NotesUIWorkspace) is also useful if you want to create your own dialog buttons. For example Close instead of Ok or Cancel. Add your custom button to the dialog form and use
@Command([RefreshParentNote])
@Comand([FileCloseWindow])


When calling the dialogbox, set noOkCancel to True.

Friday, October 05, 2007

Run Exiting/OnChange Gotcha

I've been struggling with a navigation design that relies on a combination of Dialog List and Radio Button selections to populate various folders; the code is in the OnChange() event; when triggered, it finds the necessary documents, populates and displays the appropriate folder and tracks the current and previous selection values for each field.

The setup works but there are odd behaviours that I have not been able to isolate and track.

Yesterday I was searching notes.net for references to the OnChange() event and stumbled across the following:

Very important! The onChange event will run twice for every value change: once when the user changes the value, and again when the user leaves the field...
Ah Ha! Is that the source of my problem? Did some testing today and, sure enough, that is it. Or at least, a big part of what has been causing me headaches.

This is what happens, when the user makes a Radio Button selection and the fields 'Run Exiting/OnChange' is set and there is script in the OnChange() event:
Entering onChange Event->prevVal= (Length: 0)
Entering onChange Event->currVal= (Length: 0)

Exiting onChange Event->prevVal= (Length: 0)
Exiting onChange Event->currVal= Two(Length: 3)
----------------------------------------------
And here's what happens when the user exits the same field:
Entering onChange Event->prevVal= (Length: 0)
Entering onChange Event->currVal= Two(Length: 3)

Exiting onChange Event->prevVal= Two(Length: 3)
Exiting onChange Event->currVal= Two(Length: 3)
You can see that the prevVal and currVal variables end up being equal. The script setting these values is executed twice!

By contrast, using a DialogList which does not have the 'Run Exiting/OnChange' option but has script in the OnChange() event:
Entering onChange Event->dlprevVal=
Entering onChange Event->dlcurrVal=

Exiting onChange Event->dlprevVal=
Exiting onChange Event->dlcurrVal= Cheyenne
The script in the OnChange() event is executed only once; when the field is exited.

The workaround (for the Radio Button field) is to add a third variable, load it with the current selection and compare it to the saved current value; if they match, skip the code that sets current and previous values.
 Dim ws As New NotesUIWorkspace

value$ = ws.CurrentDocument.FieldGetText("test1")
If(value$ <> currVal$) Then
prevVal$ = currVal$
currVal$ = value$
End If
I searched the help files for an explanation of what I'm seeing, this is the only entry I could find for Run Exiting/OnChange

Special Notes Client Event Options (this section appears only for certain fields, including checkbox, radio button, list box, combobox, and time zone fields).
Run Exiting/OnChange events after value change - If you check this field, the OnChange event is triggered when the value in the field is changed.
If you leave this field unchecked, the OnChange event is not triggered unless the value in the field has changed and the focus has left the field.
I wish they had worded it a little better. I was under the impression that the event would be triggered immediately if the box was checked OR, if the box was unchecked, the event would be triggered when the field was exited. Not that the event would trigger both times if the box was checked :(

Monday, July 30, 2007

Playing catch up

Wow! Hadn't realized it's been almost two months since my last post. Just haven't had the time but want to correct that now and take a moment to thank the Notes community.. while I haven't been actively participating I have been actively mining various blogs and posts.

First, thanks to Andre Guirard for his Complete Reader and Author Field Troubleshooter post on notes.net. I usually avoid using these fields, preferring to rely on the ACL groups but I couldn't get away from them last month and Andre's post helped me out, didn't realize the names had to be canonical to work correctly.

Second, thanks to Shane Hollis for his comment to enorki's SnTT entry Insert RichText into RichText with LotusScript - Chapter 2. I needed to create a rich text history field and was having some difficulty with it until I read Shane's example; it was the Call doc.removeItem("tmpHistory") that solved my problem. And thank you to the IBM Support team for supplying the cool little Unhide Rich Text Utility. I had to convert an existing rich text field that had a hide/when formula. When I copied it to the new rich text history field it carried the hide/when with it. The little utility allowed me to quickly clean up all the existing fields. (Note to self: do not use hide/when formulas on rich text fields!)

I've also been keeping an eye on Nathan Freemans Revolution posts; it strikes me as one of those techniques that is simple once you get it but which, on the surface, doesn't appear to be of any immediate use. Which means I'm not getting it. Hopefully will have some time this month to walk through the example databases carefully and think about how and where I could apply the technique.

Monday, May 07, 2007

Links and 'Object variable not set'

Tripped over my own feet on this one. I have a form with an action button with LotusScript code behind it. When new documents are created an email notifier is sent with a link back to the document. If users opened the document via the email link and then clicked the action button they would sometimes get an 'Object variable not set' error; other times it appeared to work properly.

After some poking around discovered that if the document was in a local copy of the database and that database was open the action button worked fine. But if it was in the server copy and had not been replicated to the local copy, the error occurred, even if the local copy was open.

Problem was in the action button script, I was using ws.CurrentDatabase.Database to grab a reference; the assumption being the user would only use the action button when the database was open (not always the case if they've opened the document from an email link). Changed the code to session.CurrentDatabase and the error went away.

It was a silly thing I failed to notice when I tested the form. In the future, need to remember to close the database in the designer when testing.