Cool SuperNTF Trick: db.TemplateName with @Formula
Category SuperNTF @Formula Lotus Notes Show-n-Tell Thursday SnTT
In honor
of this week's release of SuperNTF, I would like to offer up a neat little
trick that, while something of an afterthought, was made possible because
SuperNTF allows @DbLookup calls to retrieve design element information.
The challenge I had was to determine whether the current database was a
template without using LotusScript, since I was doing this in a computed
frame in a Frameset. Mind you, I'm not just talking about templates in
the .ntf sense, but also those .nsfs that are designated as a "Master
Template" in the DB/App properties:
Suffice it to say there is no handy @Formula to make this determination, let alone get the name of the Template entered as shown above. However, knowing that this information is actually stored in the database icon "note", and knowing that you can use a little hack (using $FormulaClass for those keeping score) to make a view display design element notes instead of just document notes, I set about to create a view that would contain the database icon. I ended up with four columns that display the database title and the three other text bits that you might enter on the design properties tab shown above. Here's what the view looks like:
Looking at the Category column formula you get an idea of how you have to parse the $TITLE field on the icon note to pull out the relevant values.
Once you've got this view just sitting out there, it's a simple matter of doing a DbLookup to retrieve whatever value you want. In this case, the template name is acquired using:
For the details on where in SuperNTF you will find this handy view and see how it was put to use, click "Read More".
In honor
of this week's release of SuperNTF, I would like to offer up a neat little
trick that, while something of an afterthought, was made possible because
SuperNTF allows @DbLookup calls to retrieve design element information.
The challenge I had was to determine whether the current database was a
template without using LotusScript, since I was doing this in a computed
frame in a Frameset. Mind you, I'm not just talking about templates in
the .ntf sense, but also those .nsfs that are designated as a "Master
Template" in the DB/App properties:
Suffice it to say there is no handy @Formula to make this determination, let alone get the name of the Template entered as shown above. However, knowing that this information is actually stored in the database icon "note", and knowing that you can use a little hack (using $FormulaClass for those keeping score) to make a view display design element notes instead of just document notes, I set about to create a view that would contain the database icon. I ended up with four columns that display the database title and the three other text bits that you might enter on the design properties tab shown above. Here's what the view looks like:
Looking at the Category column formula you get an idea of how you have to parse the $TITLE field on the icon note to pull out the relevant values.
Once you've got this view just sitting out there, it's a simple matter of doing a DbLookup to retrieve whatever value you want. In this case, the template name is acquired using:
@DbLookup("" : ""; ""; "lkp-design-dbinfo"; @DbTitle; 4)
For the details on where in SuperNTF you will find this handy view and see how it was put to use, click "Read More".
As you can probably guess from a close inspection of the DbLookup formula, the hacked view is called "lkp-design-dbinfo", aka "
You will find it among a few other similarly hacked views (plus some others further up the list that are not just for lookups - more on those, and how to hack them, in a later post):
Finally, the Frameset that uses this lookup is the $fslaunch Frameset, which happens to be the main launch Frameset for the whole application. It contains a single main frame which is computed to display one of four possible other Frameset: The "Dashboard", the "Standard Views", "Template Splash Page", or in rare cases the "You must have at least Notes 6 to use this application" page. Obviously the idea is to display the template page (actually a form inside another nested Frameset) if the application is identified as a template. Here's the frame formula:
REM {Depending on the Notes client version, we launch the appropriate frame};
REM {The pre R6 client frameset simply shows a 'Stop, you need R6 etc.' page};
REM {The R6 and higher frameset launches the actual DB framesets};
REM {Checks special design lookup view showing database icon, which stores template info in $Title field};
_TemplateName := @DbLookup("" : ""; ""; "lkp-design-dbinfo"; @DbTitle; 4; [FailSilent]);
IsTemplate := @If(@Right(@Subset(@DbName; -1); 4) = ".ntf" | _TemplateName != ""; "Yes"; "No");
REM {Checks DB Profile to determine whether Standard UI or Dashboard should be displayed};
UIFormat := @GetProfileField("cfg_dbconfig"; "UIFormat");
build_R6 := 190;
fs_preBuild190 := "FSLaunchPreR6";
fs_postBuild190 := @If(IsTemplate = "Yes"; "$fsTemplate"; @If(UIFormat = "Standard"; "$fsMain"; "$fsDashboard"));
@If(@TextToNumber(@Version) < build_R6; fs_preBuild190; fs_postBuild190)
And that, my friends, is how you end up here:


- 


Comments
Posted by Patrick Kwinten At 01:48:39 PM On 11/02/2008 | - Website - |