@SetViewInfo([ResetViewFilter]) (I wish)
Tags: development
Today I was struggling again with @SetViewInfo. Although the idea behind this function is very nice, the implementation sucks (a little). Basically @SetViewInfo allows to restrict a view to display only documents from a single category. This is very nice to create a "my documents" view by making the first view column categorized and hidden displaying abbreviated user names. In the PostOpen event of the view insert a few lines of code:
REM {Set view filter for user's documents};
_user := @Name([Abbreviate]; @UserName);
@Command([ViewExpandAll]);
@SetViewInfo([SetViewFilter]; _user; "TheColumnName"; 1)
The disadvantage of @SetViewInfo is that the view filter remains active until the database is closed. So you will need to somehow reset the view filter when the user switches to another view. The easiest solution would be to put @SetViewInfo([ResetViewFilter]) or some such in the QueryClose event of the view. Unfortunately this parameter does not exist. A technote suggests to put @SetViewInfo([SetViewFilter]; temp ; 0 ;1) in the QueryClose event of the view (although undocumented and unsupported). Unfortunately this only throws a "Cannot execute the specified command" error ("This problem was resolved as: No Plans to Fix Ever").
I noticed that using
@Prompt([OK]; "You are about to close this view."; "Thank you for using this view. " + @NewLine + "We hope you enjoyed your stay and are looking forward to seeing you again soon. " + @NewLine + "Please press OK to actually close this view."); @SetViewInfo([SetViewFilter]; temp ; 0 ;1)did work. Quite understandably I didn't want to be tarred and feathered by the end users for this needless prompt, so I looked a bit further and finally came across a thread in the developerWorks Notes 6 and 7 Forum where Andre Guirard finally had the solution to put an end to my ordeal. Putting
@SetTargetFrame("NotesView");
@UpdateFormulaContext;
@Command([OpenView]; @Subset(@ViewTitle; -1));
@SetViewInfo([SetViewFilter]; ""; "TheColumnName"; 1)
in the QueryClose event resets the view filter successfully.
Thanks, Andre!
If you want to reset a view filter in the current view and want to go to the top of the current view there's a nice workaround Heinz-Ulrich Krause posted about a year ago.










Comments
Unfortunately in Notes 7, Andre's solution gives me an error: "Attempt to infinitely recurse on resource link."
Back to the drawing board for me!
Posted by Simon Scullion At 09:06:07 On 11.03.2008 | - Website - |
Posted by George Marinos At 16:12:15 On 17.04.2008 | - Website - |
Any idea?
Posted by Mitch At 15:35:11 On 24.06.2008 | - Website - |
@DialogBox("SelfClosingForm";[AutoHorzFit]:[AutoVertFit]:[ReadOnly]:[SizeToTable]:[NoOKCancel];" ");
@SetViewInfo([SetViewFilter]; temp ; 0 ;1)
SelfClosingForm is a form with small empty table. Sometimes it is shown shortly, sometimes not, but it is little better than a needles prompt. It works fine..
Posted by Petr Skacha At 12:08:42 On 30.09.2008 | - Website - |
Posted by Petr Skacha At 15:04:45 On 30.09.2008 | - Website - |