« New SuperNTF Release Now on OpenNTF! | Main| SuperNTF 0.9.7d Released »

Cool SuperNTF Trick: db.TemplateName with @Formula

Category     


SuperNTF LogoIn 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:

A picture named M2

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:

A picture named M3

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):

A picture named M2

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:

A picture named M3

Comments

1 - great code!

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

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