Solved

How do I make view selection context sensitive?

Posted on 2004-04-21
25
314 Views
Last Modified: 2013-12-18
I have a database which contains two identical views except for the "View Selection" formula. One view shows all documents, the other shows a subset of the documents. The user opens views using an outline which points to each of the two different views.

My problem is that everytime I make a change to this view I have to make it twice, once to each view (note: while not a problem in my simplified case above, the reality is that I have dozens of views so it is a lot of work to update all views). What I want to be able to do is create one view and then somehow pass a parameter to the view based upon how it is opened which can then be used to modify the "View Selection" formula based upon which outline entry was used to open it.

If you're familiar with VBA in Access, I'm looking for something similar to the OpenArgs parameter that I use all the time to modify the SQL expression used to create the record source for a form.

0
Comment
Question by:glebn
  • 9
  • 6
  • 5
  • +3
25 Comments
 
LVL 3

Expert Comment

by:xp_commander
Comment Utility
If you are using Domino R6 , you can try @SetViewInfo, for example from docs :-
@Command([OpenView];"Customers");
@SetViewInfo([SETVIEWFILTER];"Acme Corp.";"companyName";1)

From documentation :-
In Standard Outline views, filters a view to display only documents from a specified category. In Calendar views, filters a view to display only document that contain a specified string in a specified column.
Note  This @function is new with Release 6.
Syntax
In a Standard Outline view:
@SetViewInfo( [SETVIEWFILTER] ; filterString ; columnName ; isCategory   )
In a Calendar view:
@SetViewInfo( [SETVIEWFILTER] ; filterString ; columnName ; exactMatch )

Check on Domino Designer Help for further reading.

0
 
LVL 19

Expert Comment

by:RanjeetRain
Comment Utility
First thing! Is it for web or Client. The method for the two type will be significantly different. I have never tried such a thing. But if this is for Client then I guess you could do it with @ENV. Do this:

-> In your outline entry set the value of an environment variable
-> Construct your view selection formulae in such a way that it makes use of that environment variable

The only thing to check is, whether @ENV is allowed in view selection formula or not. Just try it, I never really used this logic.
0
 
LVL 19

Expert Comment

by:madheeswar
Comment Utility
I heared that @Env.. will work in view selection. Even I did not tried.
0
 
LVL 4

Author Comment

by:glebn
Comment Utility
Thanks for the quick responses! I'll give the ideas above a try then and get back to you. The @SetViewInfo looks very promising! I thought I looked at every @ command, but must have missed this one.

Sorry for not including vital information. I'm using R6 and would prefer the solution to work for both web and client, but a solution for the client alone would still be a great help.
0
 
LVL 19

Expert Comment

by:RanjeetRain
Comment Utility
Hi Mady, hows it going these days!
0
 
LVL 19

Expert Comment

by:madheeswar
Comment Utility
Hi Ranjeet,
Good. may be after another 2 or 3 months need to change employee.

0
 
LVL 19

Expert Comment

by:RanjeetRain
Comment Utility
You meant to say, you want to change job after sometime?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
View selection formula is fixed. How else would it be possible to have a view show up that fast? Most of the view's info is cached, that's why they advise you to use Columnvalues and not fieldnames, even in @DbLookup. If what you're trying to do is to change views based on a sort of template view, it's not possible with Notes. There might be tools around that can do this for you, because they create views from a design database using C and the NotesAPI. I don't know a lot of these tools, maybe Ives have one, another one is IT Factory. Mucho $$...
0
 
LVL 19

Accepted Solution

by:
RanjeetRain earned 500 total points
Comment Utility
Hi Jeff,

Bro, there is a good news and there is a bad news. The good news is that you are right the way you think. The bad news is that you are wrong they way you have concluded :-D Notes does allow you to construct dynamic views based on ceratin criteria ;-) Just to make sure I tested it also.

glebn,

There is a good news and there is a bad news. The good news is that you are you are getting VERY good advices. The bad news is that no one other than me is correct :-d (hint hint)

I just tested these formulaes with a view and they all worked.

SELECT Form = @Environment("TableName")
SELECT Form = @If(@Environment("TableName") = "Sign"; "Sign"; "Default")
SELECT Form = @If(5 = 5; "FormA"; "FormB")
SELECT Form = @If(5 = 6; "FormA"; "FormB")
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Aha, but now it's me with the good and bad news, and I'm sure I'm right all over :D

Correct, I admit, the Selects above will work. That is to say: only once! Ranjeet, I suppose you never tested the view again, I mean: 1. create the env-var, open the view, change the env-var and reopen the view. Is the view different? NO. This only works with views that discard the index every time. See View's Properties, 5th tab (Advanced), and set Discard After each use. Which is probably an unwanted situation, since building up a new view every time takes a hell of a lot of time.

I'd therefore like to suggest to you to split the points in quite a different way. Hint! :D
0
 
LVL 4

Author Comment

by:glebn
Comment Utility
Wow!

Looks like I'll have to add points because there are so many ways to split them. Thanks everyone for the great answers. Again, it may take a few days before I can try everything out, but I'll try to close this out as soon as possible.

Thanks again everyone!
0
 
LVL 19

Expert Comment

by:RanjeetRain
Comment Utility
Well, you didn't try a view refresh Jeff ;-) And for such flexibility you should be ready to pay some price, shouldn't you. Ofcourse I tested the views many times before posting the comment :P

You have to pay the price glebn! Nothing comes free here :)
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
View Refresh? That's cheating! Manual intervention is prohibited, as stated clearly in the manual on page 811. And are you going to tell the poor user that he has to refresh a view when a new design is installed? The maintenance crew will love it, all the day on the 'phone ;)

As I said, there are good tools (also with a considerable pricetag ;)
0
 
LVL 31

Expert Comment

by:qwaletee
Comment Utility
It IS technically possible to copy a view, then change the resulting view's name and selection formula.  In fact, it would even be posisble to do this directly to an existing view.  Much easier in R6, but even possible in R5.
0
 
LVL 4

Author Comment

by:glebn
Comment Utility
xp commander
=========
While I thought @SetViewInfo was going to be the best solution, it is not flexible enough to be useful. The filter expression is so limited as to be next to useless. For example, lets say column "Status" contains a number corresponding to the status and I need to view all documents with statuses over 100. I can't do it! From what I can tell from reading and experimenting, all I can do is match a particular status which isn't terribly helpful. I was hoping I could enter a full fledged filter in the form of a SELECT statement. Also, although the documentation indicates that it should work wheter or not the column is a category (i.e. the final parameter for an outline view being 1 or 0), I found that it only worked when the column was a category.

RanjeetRain
========
I think your solution will work OK, but I'm having a problem opening the view from the outline as I would like to do. I created an outline entry used the following code.
@Environment(strFilter;"1");
@SetTargetFrame("frame_Main_DocFrame");
@Command([OpenView];"All Documents")

The SELECT statment works fine in the view, but the view opens a new instance rather than opening in the specified frame of the current frameset defined using the @SetTargetFrame. Any ideas what I'm doing wrong? I have a simple frameset with the left side being the outline and the right frame (i.e. frame_Main_DocFrame) displaying the view.

Note that the following code works well when used in an view action. But it would significantly change the way my UI operates so I would prefer to stick to using an outline entry to open a view rather than opening a view and then requiring the user to click an action button.
@Environment(strFilter;"1");
@Command([RefreshFrame];"frame_Main_DocFrame")

Lastly, I found that view selection statements of the form "SELECT @Environment(strFilter)"  with the envronmental set to a string like 'fld_DocType = "300"' did not work. I could never get such a statement to show any document. However, the following did work well which is the second you suggested. This is fine, but if you know off the top of your head why the first didn't work I'm very curious.
SELECT @If(@Environment(strFilter) = "1";fld_DocType = "300";@All)
0
 
LVL 19

Expert Comment

by:RanjeetRain
Comment Utility
glebn,

It surely is getting complicated. May be you will have to get dirty and get into writing some code. Because formula language seems to not be enough for it. See Qwaletee's hint, you can even redesign a view on fly and then call REFRESH method on it. But I think that would be the option you would not like to consider immediately.

The reason why @Environment doesn't waork well in all circumstances is that: the result of fetched variables are chached by Notes Client. A work around to that is: use profile document and store/fetch values from it.

As for the view being opened in a new window, Notes does a lot of stupid things. Things you can't understand. I suppose Hemantha and Qwalette helped out a user here who had a big problem about the same. Do a serach on "frame open new window" in this TA. If you don't have premium access I'll do that for you. Also, I am not sure if there is a formula language equivalent of NotesView.Refresh or NotesUIView.Refresh Hey guys, do you know of its formula language equivalent? May be then glenb can try that in his outline formula!
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Pssst, Ranjeet:
    @Command([ViewRefreshFields])
0
 
LVL 19

Expert Comment

by:RanjeetRain
Comment Utility
Jeff :-/ Does that do what I asked for?!? I always thought it was used in documents to refresh values of fields (recomputing as necessary). Have I always been wrong or you are wrong :-/
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
RTFM... See Designer Help: "Recalculates the fields in the current document OR UPDATES THE CURRENT FIELD OR FOLDER". It is more or less implied by the name, isn't it? View Refresh Fields?
:)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Eh, "... CURRENT VIEW OR FOLDER .."
0
 
LVL 19

Expert Comment

by:RanjeetRain
Comment Utility
Then glebn can use this formula command, can't he? What do you think?
0
 
LVL 4

Author Comment

by:glebn
Comment Utility
I'm swamped again with other stuff, but I'm close to closing this.

Is there a way to increase the point total for a question?
0
 
LVL 31

Expert Comment

by:qwaletee
Comment Utility
Beond 500?  No.  If you really want, you can open another question titled "points for xp_commander" or points for whatever name you wish to give more points to.
0
 
LVL 4

Author Comment

by:glebn
Comment Utility
Sorry it took so long to close, but I had to drop this project for a while.

Thanks to everyone for your help, but RanjeetRain provided me with all the solutions I eventually used. I found that I had to use code in the form of RanjeetRain's second line, namely:

SELECT Form = @If(@Environment("TableName") = "Sign"; "Sign"; "Default")

If you're curious, the actual code I used for the View Selection statement is copied below.

SELECT @If(

@Environment(strView) = "AllPublic";
fld_Private = "Public";

@Environment(strView) = "OpenPublic";
@TextToNumber(fld_Status) < 300 &  fld_Private = "Public" & (fld_Recurrence = "0" | fld_DateDue = "" | fld_DateDue < @Adjust @Today;0;1;0;0;0;0));

@Environment(strView) = "PublicRecent";
fld_Private = "Public" & fld_DateOpen > @Adjust(@Today;0;0;-14;0;0;0);

@Environment(strView) = "ClosedPublic";
@TextToNumber(fld_Status) > 300 &  fld_Private = "Public";

@All
)
0
 
LVL 19

Expert Comment

by:RanjeetRain
Comment Utility
Glad you worked it out :)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now