Search DominoPower's 10,675 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 (47 articles)
   How hide-whens in Rich Text can ruin your whole day (and what to do about it)
   Little known traps about Lotus Notes fields
   Integrating a Notes Connector database with Google Enterprise Search
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
What to look for in a Domino-based document management solution
Understanding Domino.doc end-of-life options
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
Top 10 ways to launch and build a Lotus consulting practice (with a little help from the Beatles)
Troubleshooting an OpenSuse Notes install
Incident report: denial of service attack against ConnectedPhotographer.com
Latest Lotus Headlines
SnTT - Enabling ALL the bells and whistles!
Tivoli Data protection causes Domino to crash
Fun when running DB2 CLP scripts
Introducing Flippr, the easy way to admin Quickr
DXL and fake security
Using search forms in IBM Workplace Collaborative Learning 2.7
Schmidt, Freed, and Gering on the OVF Toolkit
>> Read all the news
More from the ZATZ journals
Computing Unplugged: Eight steps to successful and reliable home backups
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Can Outlook run when it's not running (and other mysteries)?
-- Advertisement --

AUTOMATE LOTUS NOTES USER ID MANAGEMENT
ID Manager 4.5 from HELP Software provides a new level of automaton for managing Lotus Notes IDs. ID Manager lets Lotus Notes administrators get out of the business of creating and managing user IDs. Use our ROI calculator to see how quickly ID Manager will pay for itself.

Learn more about HELP Software products
-- Advertisement --

Want The Top Lotus Experts By Your Side Without Paying Hefty Consulting Fees? Look No Further.
Like having a team of consultants by your side -- ones who have all the answers and never make mistakes -- THE VIEW gives you immediate access to field-tested instruction, guidance, and best practices from the brightest Lotus professionals around.

Join your peers who realize their Lotus technology is too important to let people from blogs and forums tell them how they should implement it, run it, and use it. THE VIEW is where only the world's top Lotus experts provide validated support to you on a weekly basis to ensure you work more efficiently, get more out of your Lotus technology, and stay clear of costly mistakes.

Check out the new instruction, tips, and best practices added to THE VIEW this week.

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