Home > Domino Tips > Developer > Domino > New twist on view selection formulae
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DOMINO

New twist on view selection formulae


mark roden
08.05.2002
Rating: -3.27- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


You Can View User Feedback To This Tip

Some view selection formulae can be very complicated: This and that, or that an this but only when it is the 7th friday in April etc.

It is possible to simplify this considerably (to read anyway) by using an @If statement and @True; @False.

Unlike in normal circumstances where @if take the first true statement and ends - in the view selection formulae it takes ALL statements and bases the selection on them ALL.

Here is a small example but it can be expanded as much as you like. I have tried to keep the example as simple as possible but with this method you can embed @Ifs and it should still be quite readable.



Code

SELECT (Form="Form1") | (Form="Form2" & AddDate>@Adjust(@Today; 0; 0; -30; 0; 0; 0)) | (Form="Form3" & AddDate>@Adjust(@Today; 0; 0; -7; 0; 0; 0)) | (Form="Form4" & AddDate>@Adjust(@Today; 0; 0; -7; 0; 0; 0))

Can be rewritten as

SELECT
@If(
form = "Form1"; @True;
form = "Form2" & AddDate>@Adjust(@Today; 0; 0; -30; 0; 0; 0); @True;
form="Form3" & AddDate>@Adjust(@Today; 0; 0; -7; 0; 0; 0);@True;
form="Form4" & AddDate>@Adjust(@Today; 0; 0; -60; 0; 0; 0); @True;
@False)

USER FEEDBACK TO THIS TIP

  • I know some that would choose to code that way, but they're typically the same types that would write a couple hundred lines of lotusScript rather than one or two lines of @'s. Why would anyone (on purpose) choose to 'clean up' view selection formulas by making them programmatically more complex? Just add a few hard returns after the |'s and the original formula's fine. SELECT (Form="Form1") | (Form="Form2" & AddDate>@Adjust(@Today; 0; 0; -30; 0; 0; 0)) | (Form="Form3" & AddDate>@Adjust(@Today; 0; 0; -7; 0; 0; 0)) | (Form="Form4" & AddDate>@Adjust(@Today; 0; 0; -7; 0; 0; 0)) Is easier to read, easier to write than: SELECT @If( form = "Form1"; @True; form = "Form2" & AddDate>@Adjust(@Today; 0; 0; -30; 0; 0; 0); @True; form="Form3" & AddDate>@Adjust(@Today; 0; 0; -7; 0; 0; 0);@True; form="Form4" & AddDate>@Adjust(@Today; 0; 0; -60; 0; 0; 0); @True; @False) —Jeff Crayton
  • This seems to be saying that @If behaves differently in a view selection formula than it does elsewhere. I'm pretty sure this is not the case. The formula that uses @If is indeed more readable than the original formula given -- but the readability of the original formula could have been improved just as much by adding newlines in strategic places. If the real purpose is to avoid unnecessary @Adjusts -- a worth goal, for peak efficiency -- the formula could still be improved by being written as follows: SELECT @If( form = "Form2"; AddDate>@Adjust(@Today; 0; 0; -30; 0; 0; 0); form = "Form3"; AddDate>@Adjust(@Today; 0; 0; -7; 0; 0; 0); form = "Form4"; AddDate>@Adjust(@Today; 0; 0; -60; 0; 0; 0); form = "Form1") This assumes the four document types are approximately equally common. Note also the two formulas don't use the same @Adjust arguments; I assume this is a typo. —Andre Guirard
  • Concerning the tip "New twist on view selection formulae": While the tip is a valid one, the explanation is flawed. The submitter states "Unlike in normal circumstances where @if take the first true statement and ends - in the view selection formulae it takes ALL statements and bases the selection on them ALL." Actually, the @If still ends at the first true statement. What makes it seem like it doesn't end at that point is that the statement is evaluated separately for EACH DOCUMENT. If the original statement had been correct, the formula @If(form="myform";@true;form="myform" & myfield="";@false;@false) would not display documents with form="myform" & myfield="", because it would not have stopped at the first true statement. But in fact, this formula WILL display those documents. —Barbara Houchin
  • USER FEEDBACK TO THIS TIP

    • Cool responses from other users :) Is it worth responding to any of the comments? If you think so then add the following - if not then no worries :) To the first point - I purposefully coded it that way because the logic is easier to understand for a beginner who I was dealing with at the time. This tip isn't aimed at people who don't have any problems with Selection Formulae - it is their to make them easier to follow. To the second point - yep typo *blushes* To the third point - Thank you :) now that makes more sense! That is a very good explanation of how view indexes work :)—Mark Roden

    Rate this Tip
    To rate tips, you must be a member of SearchDomino.com.
    Register now to start rating these tips. Log in if you are already a member.


    Submit a Tip




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



    RELATED CONTENT
    Domino
    Mimic Lotus Notes Domino application functionality on the Web
    A single form to view and edit any Lotus Notes document
    DECS and DCR external data access considerations
    How to create non-scrolling Lotus Domino view headers on the Web
    Disabling the 'Submit' button on a form
    An easier way to update a rich text field
    Results from Default Notes Search have # of responses in brackets
    Lotus Notes/Domino veteran offers comprehensive list of app dev tools
    Notes to XML. . .and back again
    Creating thumbnail images using LS2J in LotusScript

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts