0
votes

once again I have to ask you for a help. I have a problem with creating public variable and using it in formula. The details of this issue is: 1, right after starting a Lotus Notes Application i have to create public variable EmpNum which will be contain an employee number (the number will be imported from IBM Blue Pages) 2, this EmpNum variable will be used to filter the data in a view, so I have to use it in formula in View Selection.

I'll be very grateful if you help with this issue. Maybe there is possible any simplest solution of this problem?

Thanks in advance, Tomasz (td2003)

EDIT: Torsten, Panu, thank you. I've decided to try write an EmpNum variable in notes.ini using @SetEnvironment and read it by @GetEnvironment, and it works. BUT (!) there is a very strange thing: 1) when I entered formula "SELECT((form="ITForm") & (Status="Completed") & (TX_EmployeeNumber=@Environment("EmpNum")))" the view shows me all document where "TX_EmployeeNumber" is EMPTY; 2) otherwise when I entered formula "SELECT((form="ITForm") & (Status="Completed") & (TX_EmployeeNumber!=@Environment("EmpNum")))" (not equal) the view shows me all document where "TX_EmployeeNumber" is NOT EMPTY and no matter if TX_EmployeeNumber have exactly the same value as EmpNum. For example: if EmpNum="P11" the view with 2nd formula shows the documents where TX_EmployeeNumber fields contains "P11", "P22", "A32" and so on.

I'm sure that @Environment("EmpNum") retrieves correct data from notes.ini.

I'm totally confused and completely don't know what's going on. Do you have any idea about this?

3
Excerpt from the help: "@Environment cannot be used in column or selection formulas"Torsten Link
Dear colleague, please take into account, that recrating the view index for every user, as you are doing here with the environment stuff, will cause a severe performance penalty to your application. Especially, if you take into account,how many userers there are in the Blue Pages. Please try to find a way to solve your problem in another way (XPages, ....). If you would describe what you actually want to achieve, maybe we can offer some alternatives ...leyrer

3 Answers

2
votes

First of all: There are NO public variables in Lotus Notes as you request it. Neither in LotusScript nor in Formula. Every variable just lives in its context, never in the complete client.

There are two places to put such a variable:

  1. in the notes.ini, where you can set / read it using Formula (@Environment, @SetEnvironment, @getEnvironent) or LotusScript (NotesSession.GetEnvironmentString, NotesSession.SetEnvironmentVar).

  2. In a Profile document in a database, where you can get it using @GetProfileField (Formula) or NotesDatabase.GetprofileDocument() (LotusScript)

Both of these approches will NOT help you for your number 2. There is only ONE View- Selection- Formula for ALL Users. Putting something "userspecific" in there will let it render correctly for ONE value (the one, that the server uses when building the view- index), but not for all the others.

To solve your problem you can use:

a) An embedded View

  1. A view that is categorized by empNum
  2. A Form that has this view embedded and a Formula for "Show single category" for this embedded view set

b) A SPOFU view

SPOFU is "Shared, private on first use" and means, that every user has his own copy of the view. These views have some caveats and are hard to maintain. You should NOT use them, if you are not totally aware of the implications (getting the ACL right is one very important thing for these views)...

EDIT (due to change in question): SPOFU will neither work with Environment nor with Profile- documents, as the methods to read them are not supported in Views... So b) is not really an option... Sorry...

1
votes

It is possible to use the @SetViewInfo formula in the QueryOpen and/or PostOpen of a view to get the view to only present data from one category. Be careful with this because you will need to touch EVERY view so that the value is cleared if the user navigates to a view which is not categorized by the employee num...

FWIW: I only have done this using @UserName not with another piece of data. I suggest you do that by having the import process add the fully qualified Notes name of the user to the documents as they are imported.

0
votes

You can modify view selection formula with NotesView class. In this case you would have to use private views.

A better solution would be to use an XPage to show the view and use category filter. Or if you want to use traditional style then embed the view to a form or page and use "Show Single Category" feature.