Search DominoPower's 11,441 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
PROGRAMMING POWER
How to create subforms that configure other subforms
By Chris Doig

Here's a scenario. You have written a marvelous subform called RevHistory that creates a full audit trail of all document changes, as seen in Figure A. Applications are endless, and the paranoid want you to use it everywhere.

FIGURE A


You're now the proud owner of this handy RevHistory subform. Roll over picture for a larger image.

To make RevHistory a general-purpose subform for your library, you create the RevHistory Setup subform. This subform goes on a tab on the database profile form and configures RevHistory for that database.

But there's a problem! For RevHistory to get the setup parameters from the RevHistory Setup subform, you must know the name of the database profile form. However, you can't hard-code the database profile form name because that would mean your subform would no longer be a general-purpose object.

How can you get information from the setup subform when you don't know the name of the database profile form?

The solution
The trick is to use an intermediate profile document. The RevHistory subform gets the name of the database profile form from this intermediate document and then opens the database profile. Here's how you do it.

On your RevHistory Setup subform you include the code to create the intermediate profile document automatically. The first time you save the database profile document that contains the RevHistory Setup subform, your code creates the intermediate profile document with a known form name. (Although it has a form name, this intermediate document does not actually require a form.)

When you save a document with the RevHistory subform, it uses this known profile document to look up the name of the database profile document. Voila! You have a handle on the database profile document with the setup information.

Creating the intermediate profile document
The script below goes in the PostSave event of the database setup profile document. This script creates an intermediate profile document every time you save the database profile document. If you rename your database setup profile document, you must open it and save it in order to update the intermediate profile document with the name of the new database setup profile document.

Sub Postsave(Source As Notesuidocument)
'The RevHistory Setup subform can go on a db setup form of any name.
'However, the RevHistory script must know what form this is.

'This script creates a "link" profile document. The RevHistory script
knows the name of the "link"
'document, and uses it to find the db setup document that contains the
RevHistory setup subform.
'This code automatically creates a "link" profile document, if one does
not exist.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim Profiledoc As NotesDocument
Dim doc As NotesDocument


Set db = session.CurrentDatabase
Set doc = source.Document
Set Profiledoc = db.GetProfileDocument("RevHistory Profile")
Profiledoc.RevHistoryForm = doc.form(0)
Call Profiledoc.Save(False, False)
End Sub


1  ·  2  ·  Next »
Other articles you might like
Home > Lotus Technologies > LotusScript (64 articles)
   When the debugger won't debug hidden code that isn't hidden
   What to do if the LotusScript debugger won't single-step over code
   Little known traps about Lotus Notes fields
Home > Lotus Technologies > Application Development (48 articles)
   An application for scanning physical mail and distributing it virtually
   How hide-whens in Rich Text can ruin your whole day (and what to do about it)
   Little known traps about Lotus Notes fields
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Application development, William Shatner, and the origin of the universe
Learn Domino Designer 8.5 for free
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Latest Lotus Headlines
Xpages not loading? JVM errors? - Solution
How to implement an iCalendar feed into your Notes calendar with XPages
DWA Hotfixes for Domino 8.5.1FP1 - A Gotcha
IBM Adds DB2 to Lotus Foundations SMB Package
SNTT : XPages onclick Ghosts in the machine
Ports used by Lotus Sametime 8.5 servers
Exploring a Domino Date Bug
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
OutlookPower: More about disappearing text
-- Advertisement --

Find unused Lotus Notes groups and clean up your address book
Have you ever wanted to get rid of old Lotus Notes groups that were cluttering up your address book, but you weren't sure if they were used? Find Unused Groups can help.

Find Unused Groups will check your ACL, mail, multi purpose and server groups to help you determine if they are used, and who uses them.

Learn how to easily clean up your address book.

-- Advertisement --

Struggling with exporting Notes data to spreadsheets? No More!
Try IntelliPRINT, The world's leading Reporting, Dashboards, and Analysis solution for Notes & Domino

  • Don't spend unproductive time maintaining different versions of the same spreadsheet
  • Preserve data integrity and security in multi-user environments
  • Create reports in minutes INSIDE Notes
  • Get freedom from iterative report requests, deliver self-serve capabilities

Experience Reporting, Dashboards, and Analysis INSIDE Notes.

Try IntelliPRINT NOW!

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login