We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

@Adjust Question

witgrefe
witgrefe asked
on
Medium Priority
333 Views
Last Modified: 2013-12-18
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
Comment
Watch Question

Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
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?

Commented:
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
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
Won't work in a view's SELECT statement. @Environment will work, but using it in a view is not good.

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

Marko

Author

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
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
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...

Commented:
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.

Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
Now where did I read that before... In a more concise version, of course ;)

Commented:
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

Author

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.
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
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.

Commented:
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
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
To create or change a view, you need Designer privilege...
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
Ignore that last remark. You need some privilege, i.e. to create personal views.

Commented:
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
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
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.

Commented:
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
Sjef BosmanGroupware Consultant
CERTIFIED EXPERT

Commented:
Which "proves" my point: don't design views "on the go"

Commented:
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
Groupware Consultant
CERTIFIED EXPERT
Commented:
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... ;)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
witgrefe,
which solution did you use?
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.