Veasna
Veasna

Reputation: 143

Lotus notes - error accessing shared private on first use view from LotusScript

Good morning,

I have develop a note application which is used to make a booking. This application is used by multiple user at the same time. I am quiet new to this development and now I would like to develop a functionality so that user can print a export data to excel.

I have created a view (Shared) where its Selection Formula is base on critical each user specify in a search form. I have problem when a user is being printing and yet finished, the other users is also clicking printing same time, the result of export data on the sides are the same to the one who created first.

I was thought may be using the kind of (Shared, Private on first Use View) but it generated an error [Notes error: Index is not to be generated on server ("view name") ] at the points where I called

view.Clear    
view.SelectionFormula = formula   
uiw.ViewRebuild

I have no idea how to solve this problem. Could you please advice how this problem could be solved?

Thanks your in advance for your great help.

Best regards,

Veasna

Upvotes: 1

Views: 893

Answers (3)

Richard Schwartz
Richard Schwartz

Reputation: 14628

According to this thread on the Notes 6/7 forum, there may be a workaround for this problem. You haven't shown enough code to know for sure. If you are using getView() to access the Shared - Private On First Use (SPOFU) view, that doesn't work. The workaround is to loop through the db.Views() array, checking both the Name and Readers properties in order to make sure that you get a handle on the private instance of the view instead of the shared instance.

Upvotes: 0

Karl-Henry Martinsson
Karl-Henry Martinsson

Reputation: 2795

You could create a Lotusscript agent to export the data the users specify. Get the search criteria from the form, then use db.Search or (preferably) db.FTSearch to get the documents to export. Now you can export the data of those documents to Excel, using one of the techniques described here: http://blog.texasswede.com/export-from-notes-to-excel-3-different-ways/

If you want to export as CSV, you can use this code as a start: http://blog.texasswede.com/export-notes-view-to-excel-with-multi-value-fields/

Upvotes: 0

Tode
Tode

Reputation: 12060

There are different ways to do this. One possibility is to use a "shared, private on first use" (spofu) view: then every user gets his own copy of the view, and they don't impact each other. But I think it is not a good idea to do it like that, as every user needs designer rights to change the selection formula of the view. This is something you do not want.

A better way would be to use a spofu folder for each user and put the documents in it like this:

Dim ses as New NotesSession   
Dim db as NotesDatabase
Dim dc as NotesDocumentCollection
Dim folder As NotesView
Dim formula as String

Set db = ses.currentDatabase
Set folder = db.GetView("NameOfTheSpofuFolder" )
'Make it empty
Call folder.AllEntries.RemoveFromFolder("NameOfTheSpofuFolder")
'Search documents based on the formula
Formula = "Field1 = 2 & Field2 = 5"
Set dc = db.Search( formula, Nothing, 0)
Call dc.PutInFolder("NameOfTheSpofuFolder")

Spofu folders need a little "care" but usually they work quite nicely.

This code is not tested and just written down without syntax check etc. It might contain typos, but should give you an idea how to start.

Upvotes: 2

Related Questions