Link to home
Start Free TrialLog in
Avatar of witgrefe
witgrefe

asked on

@Adjust Question

I am using the following selection formula in a view and I was wondering if it would be possible to have the number of days (-2) in the adjust formula extracted from a setup document thereby making it unnecessary to have to change it in the formula

startdate:=@Adjust(@Today;0;0;-2;0;0;0);
SELECT  (Form = "PC" | Form = "PCW") & @Created > startdate
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Is this for a personal view or for a shared view?

Could this be handled using an agent that selects the documents, puts them in a folder (personal or shared) and then switches to the folder?
Hi witgrefe,
what is setup document?

If it's the profile doc then use:
    @GetProfileField( profilename ; fieldname )

If you have document's unid use:
    @GetDocField( documentUNID ; fieldName )

Hope this helps,
Marko
Won't work in a view's SELECT statement. @Environment will work, but using it in a view is not good.
sjef_bosman,
you're right, I didn't read carefully - "setup document" got all my attention.

Marko
Avatar of witgrefe
witgrefe

ASKER

The setup document is just a form where the user can set certain parameters, nothing special. I was hoping the value could be pulled from there and used in the selection formula
Yes, it can be done, but Notes views aren't constructed for that kind of work. Views usually are pretty static things, they are constructed once, the SELECT is evaluated once (unless there's an @Today in it), in order to make them fast. So if you want to change the view's SELECT statement, you can use @Environment to get a parameter from the Notes.ini but you have to update the view's index afterwards. Furthermore, if other people use the same view, they use the same SELECT...
Agreed,  But you can always have an agent run that selects the documents and puts them into a private folder for the viewer.  Each time it runs it removes the documents in the folder and adds the new ones, or you can prompt the user to see if they want to add to existing or remove existing.

This way you can also ask them how many days to search for, too.

Now where did I read that before... In a more concise version, of course ;)
Guys
How abt using Selectionformula method of notesview class and change it accordingly (R6 though !)

Example from help:

Dim ws As New NotesUIWorkspace
  Dim uiview As NotesUIView
  Dim view As NotesView
  Dim formula As String
  formula = "SELECT (@Modified > [" & (Date - 7) & "])"
  Set uiview = ws.CurrentView
  Set view = uiview.View
  view.SelectionFormula = formula


Partha
Hello All,
what I am doing is gathering statistics from a database that holds thousands of documents (trranslations) an agent purges documents when they are 60 days old.  The statistics will be automatically gathered daily by an agent that runs near to midnight when there is not too much activity.  It then creates a report.  The first thing it does is read the setup doc to establish location of databases and other information it needs.

Now, because there are tens of thousands documents, if I run the agent on them all it takes a long long time.  So I have created a hidden view for the agent to use in which I can select the number of days for the documents to be displayed and this is where I wanted to have it grab the parameter from a setup doc because I also use the number of days in the view in various calculations and that means that I have to hardcode the number of days into the agent instead of being able to pull it from my setup doc.
Two remarks then:
1) To remove documents that are more than 60 days old, don't use an agent but set ofne of the space savers properties of the database: File/Replication/Settings, Space Savers, Remove documents not modified in the last -> 60 days. Very clean, the server will do the work for you.
2) You gain a lot of flexibility and speed when you enable FullText-searching and you creat the right search-string to find the documents you need. The syntax for FTSearch() is more difficult than for Search(), but there is a lot to be gained. If everything stays invisible to the user, there is no real need to create a view. Anyway, that view would have to be rebuilt every time, at considerable cost. I suggest to use FTSearch.
witgrefe,
you can consider creating the view programatically, from LotusScript.
Here's an example of view that contains all docs in the db that are created before last midnight with form "FrmName":

    '...
    strSelect = |SELECT ( Form =  "FrmName" ) & ( dateFieldName1 < @Date( @Today )|    
    Set viewTemplate = db.GetView( "(TemplateViewName)" )    'Use this if you want view created by copying the existing view (uses all of template's design except view's name and selection formula)
    Set viewNew = db.CreateView( "NewViewName", strSelect, viewTemplate )
   
    'loop through all view's docs
    Dim cur As NotesDocument
    Set cur = viewNew.GetFirstDocument()
    Do Until cur Is Nothing
   
        Set cur = viewNew.GetNextDocument( cur )
    Loop
    '...
   
    'after the calculation you can delete the newly created view
    Call viewNew.Remove
    '...

Hope this helps,
Marko
To create or change a view, you need Designer privilege...
Ignore that last remark. You need some privilege, i.e. to create personal views.
But, as I understood, this process of collecting stats is done by an agent.
That means that the agent can be run on behalf of someone who is Manager od Designer, or can be signed with the Manager's or Designer's ID.

Am I right Sjef?

Marko
True, true, but then it can never be an agent that is started by any user. If that's no problem, then do that. IMHO, creating a view just to throw it away a few minutes later can't be the right solution.
When the user doesn't have Designer access and runs the agent Notes crashes (NSD) when trying to create view,
but if the user is Editor (or above) and has option Create shared Folders/Views in ACL enabled everything works fine.
Running LN 6.5.1

Marko
Which "proves" my point: don't design views "on the go"
sjef_bosman,
> IMHO, creating a view just to throw it away a few minutes later can't
> be the right solution

Why not?
If that works and works fast (remember FTSearch on massive dbs) and the view is deleted afterwards and all together does the job, then I consider it to be a good workaround (trick).
Inspite of all that, I suggest not using this code on production db before thorough testing, especially if the @Today (or other current date/time related functions) is used.


> Which "proves" my point: don't design views "on the go"
This doesn't prove your point (want an analogy? ;)


Regards, I'm going home, see you tommorow,
Marko
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
witgrefe,
which solution did you use?