IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

The requirement:

Create a "my documents" view for the user.

The obstacle:

@Username can't be used in a shared view selection formula. That's because for a view index calculated by the server, @Username is the name of the server.

Common approaches:

  • Create a "Desktop private on first use" view; now if you use @Username, it's the user's own name. Drawbacks are that it tends to be slow, especially the first time it's used, takes up space on the user's disk, and updating the design of the view is a challenge since there's nothing to force an update of users' private copies.
  • Use NotesView.SelectionFormula to update the view's selection formula every time someone opens it. This is a really dumb idea for several reasons: it's slow, it requires users have Designer access, changes to design elements at runtime often don't work well since the client caches design elements, and users would interfere with each other by using the view at the same time. Don't even think about doing this.
  • Create a single view containing all users' documents, categorized by username. Then use the view in a way that has it display only a single category. There are two ways to do this in the Notes client:
    • Embed the view on a form or page design element, and use a Single Category formula such as @Username or @V3UserName. Very easy, but there are some things that don't work so well in an embedded view, including full-text search, sort by clicking column headers, and view links and bookmarks.
    • Open the view as you normally would, but use Postopen view event code to limit the display to the user's category by means of a call to @SetViewInfo.
It's this last technique I describe below.

How to Do It:

The formula for the view Postopen event is:

@SetViewInfo([SetViewFilter]; @UserName; "columnName"; 1; 1)

where you would substitute the actual column name of the categorized column, in place of columnName.

The formula for the view Queryclose must clear the limitation, or it will affect other views in your application. Here's the formula for that:

@SetTargetFrame("frameName");
@UpdateFormulaContext;
@Command([OpenView]; @Subset(@ViewTitle; -1));
@SetViewInfo([SetViewFilter]; ""; "columnName"; 1)

where you need to substitute for frameName, the name of the frame containing your view, and for columnName, the name of the categorized column. This assumes the view is displayed in a frame of a frameset, as is typical for a Notes client application. If it is not the case for your application, you can leave off the first line.

The purpose of opening the view that's already open, as we do in line 3 of the Queryopen formula, is to cause focus to enter that frame, in case it is elsewhere (as it probably will be if you clicked on a link in another frame to switch to a different view). If you don't do this, @SetViewInfo may fail because it's a view command being used in a frame that doesn't contain a view.

Limitations:

  • The functionality 'Click on column header to sort' is not available. You can, however, use this same technique in multiple views that use different sorting after the category column, and click on column header to switch views.
  • If you do a full-text search, the status bar will display the number of hits for the whole view, not just your category (but only the matches from your category will display).

Andre Guirard | 20 July 2010 03:56:55 PM ET | Man-Cave, Plymouth, MN, USA | Comments (11)

Search this blog 

Disclaimer 

    About IBM Privacy Contact