@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
witgrefeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantCommented:
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?
0
mbonaciCommented:
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
0
Sjef BosmanGroupware ConsultantCommented:
Won't work in a view's SELECT statement. @Environment will work, but using it in a view is not good.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

mbonaciCommented:
sjef_bosman,
you're right, I didn't read carefully - "setup document" got all my attention.

Marko
0
witgrefeAuthor Commented:
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
0
Sjef BosmanGroupware ConsultantCommented:
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...
0
marilyngCommented:
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.

0
Sjef BosmanGroupware ConsultantCommented:
Now where did I read that before... In a more concise version, of course ;)
0
p_parthaCommented:
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
0
witgrefeAuthor Commented:
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.
0
Sjef BosmanGroupware ConsultantCommented:
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.
0
mbonaciCommented:
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
0
Sjef BosmanGroupware ConsultantCommented:
To create or change a view, you need Designer privilege...
0
Sjef BosmanGroupware ConsultantCommented:
Ignore that last remark. You need some privilege, i.e. to create personal views.
0
mbonaciCommented:
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
0
Sjef BosmanGroupware ConsultantCommented:
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.
0
mbonaciCommented:
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
0
Sjef BosmanGroupware ConsultantCommented:
Which "proves" my point: don't design views "on the go"
0
mbonaciCommented:
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
0
Sjef BosmanGroupware ConsultantCommented:
Creating a view on a huge database is VERY time-consuming. FTSearch is a lot faster. The fastest solution would be a permanent view with all documents sorted by creation date in the first column, in the format yyyymmdd to enable simple searching (if required

Regarding "proves": that's why I put it in double-qoutes... ;)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mbonaciCommented:
witgrefe,
which solution did you use?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.