Manage Learn to apply best practices and optimize your operations.

Let users filter any view

Here's a great little Action (or Agent) that lets a user filter any categorized view based on whichever category they choose.

View member feedback to this tip.

Here's a great little Action (or Agent) that lets a user filter any categorized view based on whichever category they choose. I suggest putting it in a SmartIcon so that it will be available in any database or view. You may want to put it in an action button at the top of certain categorized views. It is super-fast (much like using an embedded single-category view). I have put error handling for everything that I encountered, so the user will always get a friendly message.

The @SetViewInfo function filters a view down to a single category. Calling it with a null value will reset the view to show all categories.

This is helpful because of an ugly side-effect of @SetViewInfo -- filtering is retained even when the user changes to a different view. Sometimes this results in zero documents being shown. Clicking the action button again will show all docs.

By the way, I believe that the column choice does not work in @SetViewInfo( ). In my testing, it only works on the first categorized column.

Code:

REM { --- this action button 
filters a view based on the user's input ---
 };

tmpVName := @Subset( @ViewTitle; -1 );
@If( tmpVName = "";
   @Return( @Prompt( [Ok]; "Warning";
 "This only works when a database
is opened to a view.") );
   @Success );
tmpCol := 1;

REM { produce a list of categories
 from the current view };
tmpList := @Unique( @DbColumn( "":"";
 "":""; tmpVName; tmpCol ) );

REM { handle common errors -- reset 
filtering in an inappropriate view };
warningText := "This action only works 
in a categorized view where the category
is the first column." + @Char(10) +
  "This will not work in a flat view or in a 
view where the first column is not
the category";
@If( @IsText( tmpList[1] );
   @Success;
   @Do( @SetViewInfo( [SetViewFilter]; ""; 
""; 1); @Return( @Prompt(
[Ok]; "Warning"; warningText ) ) ) );

REM { Let the user pick one category };
tmpChoice := @Prompt( [OkCancelCombo];
 "Select a Category for Filter"; "This will f
ilter the view to a single
category." + @Char(13) + "  
 (specify blank for all)";
 ""; "" : tmpList );

REM { reminder: expand the view or it 
may appear empty };
@Command( [ViewExpandAll] ) ;

REM { Set the filter (or clear the filter) };
tmpCName := "sPOAreaName";
@SetViewInfo( [SetViewFilter]; tmpChoice;
 tmpCName; 1 )

MEMBER FEEDBACK TO THIS TIP

I just wanted to point out that @SetViewInfo is not available in R5. The tip does not indicate this fact and it really should mention that. Thanks.

—Christie S.

******************************************

So many of my views are categorized by date, it doesn't work on those. But the few I have by customer name, I thought it worked nicely.

—Leslie M.

********************************

When I use Ctrl+A (Edit -> Select All) I get All Documents selected, even the filtered out ones. Is there any way to get only shown entries selected?

—Marco Crivellari (kri@soluzioni-sw.it)

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Doug Jamieson. Please let others know how useful it is via the rating scale belowtip. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on Lotus Notes Domino Formula Language

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close