HI,How can I reset the value of a NotesUIView… I explain…
I have an embeded Folder in a form.
This folder contains documents with categories and a Action button in the action bar
(see the code: removeSelectedDocFromFolder)
When I click for the 1st time its work perfectly
(If I select a doc it will be remove… If I select a category I have a popup message)
…but when I click after 1 doc remove (or many), the button doesn’t popup the message when I selected a category (instead of doc)
Here the code:
Sub removeSelectedDocFromFolder
' Cette fonction enlève le(s) document(s) sélectionné(s) du folder actuel
' Elle est appelée par les boutons <Enlever les Taches du Rapport> qui se trouvent sur les Folders
Dim ws As New NotesUIWorkspace
Dim viewUI As NotesUIView
Dim doc As NotesDocument
Dim docCol As NotesDocumentCollection
Dim nomVue As String
’ Set viewUI = Nothing’ On doit vider la variable doc en cas de 2e appel de cette fonction
Set docCol = Nothing ' On doit vider la collection de document en cas de 2e appel de cette fonction
Set doc = Nothing ' On doit vider la variable doc en cas de 2e appel de cette fonction
Set viewUI = ws.CurrentView
Set docCol = viewUI.Documents
Set doc = docCol.GetFirstDocument()
Msgbox "docCol = " & Cstr(docCol.Count) & Chr(13) & "viewUI.ViewAlias = " & viewUI.ViewAlias & Chr(13) & "docUID = " & Cstr(doc.UniversalID)
If docCol.Count = 0 Or doc Is Nothing Then
Messagebox "Vous devez sélectionner au moins une tâche en lui mettant un crochet dans la colonne de gauche." & Chr(13) & Chr(13) & "NOTE: sélectionné un document (ex: date) et non une catégorie (POs).", 48, "Erreur"
Exit Sub
End If
nomVue = viewUI.ViewAlias
cmpt =0
While Not(doc Is Nothing)
cmpt = cmpt +1
Msgbox Cstr(cmpt)
Call doc.RemoveFromFolder(nomVue)
Set doc = docCol.GetNextDocument(doc)
Wend
Call ws.ViewRefresh
End Sub
I think this is because NotesUIView keep the value of selected doc (If I dont select a doc for the 2nd time, I keep docCol.count at 1 instead of 0).
Any Idea?
Thanks in advance
Subject: removeSelectedDoc function in LS How can I reset NotesUIView?
I would avoid manipulating the docs in the front end UIView and instead grab the backend view and do it there, since you are essentially doing that with a doc collection. The reason it doesn’t update is because the doc collection is separate from the UIView. If you make changes using view.GetFirstDocument, etc. the view’s AutoUpdate default setting of true will do what I think you are attempting to do. Once the processing is done, you can call a ws.RefreshView to show the changes.
hth.
brandt
Subject: RE: removeSelectedDoc function in LS How can I reset NotesUIView?
OK but How can I create a collection without UIView?
in my code I used
Set docCol = viewUI.Documents 'for collection of selected doc
Set doc = docCol.GetFirstDocument()
How can I use a NotesView object with the same result?
Thanks
Subject: RE: removeSelectedDoc function in LS How can I reset NotesUIView?
Dim view as NotesView
set view = uiview.View
set doc = view.GetFirstDocument
Check Notes help for the back end NotesView object properties and methods…GetFirstDocument and GetNextDocument in particular.
brandt
Subject: RE: removeSelectedDoc function in LS How can I reset NotesUIView?
Thanks for your advicebut I’m still confuse!..
Sub removeSelectedDocFromFolder
Dim ws As New NotesUIWorkspace
Dim viewUI As NotesUIView
Dim view As NotesView
Dim doc As NotesDocument
Dim nomVue As String
Set viewUI = ws.CurrentView
Set view = viewUI.View
Set doc = view.GetFirstDocument
'Set docCol = viewUI.Documents ’ My Selected docs
'Set doc = docCol.GetFirstDocument() ’ My 1st Selected doc
If doc Is Nothing Then
docID = "Nothing"
Else
docID = Cstr(doc.UniversalID)
End If
Msgbox "docUID = " & docID
…
…
In that case, the doc is ALWAYS the first doc in folder INSTEAD of the FIRST SELECTED DOC of my folder
I don’t figure how can I replace docCollection for Selected Doc
Thanks
Subject: RE: removeSelectedDoc function in LS How can I reset NotesUIView?
Whether it is a view or a document collection, you will always need to loop through the collected docs.
Do while Not (doc is Nothing)
...run your code here...
set doc = view.GetNextDocument(doc)<--grab next doc in the collection/view
Loop
You need to take a good look at the Notes documentation. This is all spelled out under the GetFirstDocument/GetNextDocument method documentation.
brandt
Subject: RE: removeSelectedDoc function in LS How can I reset NotesUIView?
I Brandt, I really appreciate your time for my case but I don’t have any problem with GetFirstDocument or GetNextDocument methods.
The problem is about to figure I how can I regroup all the doc who are Selected by the user in the margin of the embeded folder.
Then remove them (selected docs) from the folder (notesdocument.removefromfolder(foldername)).
In my old code the I used:
Set docCol = viewUI.Documents
to regroup all the Selected Docs and is working fine.
But… when I already remove a doc from the folder I’m not able to know if the user didn’t select a doc OR if he select a category (I just need to show a error msgbox in that case) for the 2nd time (the 1st click work fine).
========
now if I use notesView instead of notesUIView class I don’t think its possible to know which document(s) is (or are) selected
=============
Remember:
My folder are categories and the users must select at least a doc (not a category).
If he doesn’t select a doc I have a NotesError (Canot execute this Command) but I don’t want that error I want my own.
That case append AFTER the user already removes a doc from a folder and the user try to remove some others documents for another time (in the same window).
================
Thanks
I hope I’m much clear