uiview.SelectDocument not working like I need it to

I have a view where I need the client to select only one Unit document. Then then click a button to create subunit documents…which inhereit info from the Unit document. I ask them to “check” the Unit document to select it.

In all my testing I usually had been looking at the unit document prior to checkign it and creating a sub document…so that unit document was bascially “highlighted” or in focus at the view level.

What I am finding is that some of my users are checking the Unit document in the view while having the focus on aonther document or category heading. THis causes an error cuz hte subunit document needs data from teh unit document to inherit…so I need to not only select it in the margin but also have it in focus.

I have tried using the uiview.SelectDocument(doc) to do this and it moves the “focus” down to the selected document but it’s not really taking…it’s like it moved it but it’s not refreshed or something…after the script is done and the subunit docuement errors out the Unit document is now in focus…

Sorry if htis is very confusing…

Any thoughts??

Thx,

ER

Subject: uiview.SelectDocument not working like I need it to…

Get the collection and get the first document in collection. This way you will not have any problem.

dim col as NotesDocumentCollection

set col = db.UnprocessedDocuments (from uiview, you get a collection of those selected documents. If only one is selected, that will come into the collection and hence the next line)

set doc = col.GetFirstDocument

or

Dim col As NotesDocumentCollection

Dim doc As NotesDocument

Set uiview = ws.CurrentView

Set col = uiview.Documents

Set doc = col.GetFirstDocument

You can pop up a message and exit for user, if the document selection is more than one in collection.

If col.count > 1 then

msgbox “Please select only one document”

exit sub

end if

Subject: uiview.SelectDocument not working like I need it to…

thanks for the ideas…I do have alot of other checking to make sure they do not select more than one document and I am getting the document ok…I check the Unit document against the current user to make sure someone is not trying to create a subunit doc (actually employee survey) from somene elsees unit doc.

OK…I’m a hacker and I know the next part is going to get me laughed off the site…I think my major problem is that I have a bunch of fields on the Employee Survey that inherit default values from Unit…the only way I could get these values to populate was to be “sitting” on top of the unit document during creation. So after I check the collection to make sure they’ve only checked their one unit document I do the following:

Call uiview.SelectDocument(doc)

Set uidoc = ws.ComposeDocument _

( "", "", "Employee Survey" )



Call uidoc.GotoField("Employee")

Call uidoc.InsertText(sAdd)

Call uidoc.GotoField("SurveyType")

Call uidoc.InsertText("Employee")

Call uidoc.Save

Call uidoc.Close	

I know it’s kinda clunky…but when I tried doing a doc2.save on teh employee document it was not really saving all the fields on that documetn for me…it’s as if I needed to have the document opneed in the front end for all my computed fields to instantiate …

Unfortunately it’s working as long as someone selects the unit document prior to clicking the button to create the employee survey…it only breaks when they are not “sitting” on top of the unit document.

So, if there’s a hack out there that will allow me to bring that “getfirstdocument” from a collection into focus so that I’m sittign on top of it that would be great.

THanks for humoring me!!!

ER

Subject: RE: uiview.SelectDocument not working like I need it to…

If you have fields which get their values set via formulas try adding the ‘ComputeWithForm’ method of NotesDocument prior to saving Doc2.

Alex

Subject: uiview.SelectDocument not working like I need it to…

check this thread:

http://www-10.lotus.com/ldd/nd6forum.nsf/ShowMyTopicsAllFlatweb/86a54e91a4e3a49585257274005d4a18?OpenDocument

Subject: uiview.SelectDocument not working like I need it to…

You can use ‘NotesDatabase.UnProcessedDocuments’ and call GetFirstDocument in the returned collection. This will give you a handle to the ‘checked’ document irrespective of which document is highlighted in the view.

Two things to be aware of:

  • If the user selects more than one document in the view (ie. puts a checkmark next to more than one document) then ‘NotesDatabase.UnProcessedDocuments’ will return all selected documents. In this instance you could probably popup an error advising them to select only one document. Just check the NotesDocumentCollection.Count property.

  • The button in the view should call an agent and the agent has all your processing code because ‘NotesDatabase.UnProcessedDocuments’ does not work correctly from a button in a view. Simply put '@Command([ToolsRunMacro]; “”) in the button in the view.

Alex