Effacer le contenu d'un folder

Forum destiné aux questions sur le développement : Formules, LotusScript, Java ...

Effacer le contenu d'un folder

Messagepar Seve » 29 Jan 2004 à 18:11

Comment puis-je effacer le contenu d'un folder (sans supprimer les docs de la base) à partir d'un bouton situé dans un masque ?Désolé pour mes questions ennuyeuses, je suis très débutante !!!
Seve
 

Re: Effacer le contenu d'un folder

Messagepar oguruma » 29 Jan 2004 à 18:41

tiré de l'aide en ligne Call notesDocumentCollection.RemoveAllFromFolder( folderName$ )Dim session As New NotesSessionDim db As NotesDatabaseDim collection As NotesDocumentCollectionSet db = session.CurrentDatabaseSet collection = db.FTSearch( "cayenne", 20 )Call collection.RemoveAllFromFolder( "Recipes\Spicy" )
Bien à vous

http://www.dominoarea.org/oguruma/

Les téléphones PORTABLES dans les TGV y en a MARRRE de ces voyageurs qui ne respectent pas les autres ! ARRET DES PORTABLES SVP - Merci

Fumeurs ! respectez les non fumeurs !!!
Fumeurs ! respectez la loi de février 2007 et les lieux publics !!! (ie. hall de gares)
Avatar de l’utilisateur
oguruma
Super V.I.P.
Super V.I.P.
 
Message(s) : 4086
Inscrit(e) le : 16 Déc 2004 à 08:50
Localisation : LILLE

Re: Effacer le contenu d'un folder

Messagepar oguruma » 29 Jan 2004 à 19:00

si ça peut encore t'aiderissu de ma Kbase NotesHow to Get a NotesDocumentCollection that Contains All the Documents in a View or FolderProblem:For some applications, you may wish to get a NotesDocumentCollection of all the documents in a view or a folder. Typical uses are for removing all documents from a Folder (RemoveAllFromFolder method) or for marking all the documents as processed (UpdateAll method). Is there a way to create a collection from the documents within a view or folder?Solution:There are two ways to create a collection of documents in a view or folder. One of the methods can be used only if the view or folder is currently open in the User Interface (Front End), the other can be used from either the Back End or the User Interface (Front End).Front End/User Interface Method:This example removes from the folder "MyFolder" all the documents in the presently opened view or folder.The agent setting "Which document(s) should it run on?" should be set to "All documents in view." Dim session As New NotesSession Dim db As NotesDatabase Dim collection As NotesDocumentCollection Set db = session.CurrentDatabase Set collection=db.UnprocessedDocuments Call collection.RemoveAllFromFolder("MyFolder")Back End Method:This example removes all the documents from the folder "MyFolder".1. In the view or folder in question, append at the beginning a column to act as a key column. Set the properties of the column to be: hidden, sorted.2. Assign the value " " (or any character) to the column. 3. The agent setting "Which document(s) shoult it run on?" should be set to "Run Once". Dim session As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim collection As NotesDocumentCollection Set db = session.CurrentDatabase Set view = db.GetView( "MyFolder" ) Set collection = view.GetAllDocumentsByKey(" ", False) While collection.count <>0 Call collection.RemoveAllFromFolder("MyFolder") view.refresh Set collection = view.GetAllDocumentsByKey(" ", False) WendNOTE: The loop is needed only if any column following the Key column is categorized. In such cases, the initial GetAllDocumentsByKey call will return only the documents in the first category.>>>How to Use LotusScript to Remove All Documents from a FolderProblem:Using LotusScript, how can you remove all documents from a folder?Solution:The example below demonstrates how to use the RemoveFromFolder method of the NotesDocument class to remove documents from a folder. Note: Removing a document from a folder does not delete it; the document is simply no longer contained within the noted folder.The following agent could be triggered either manually or scheduled. It should be set as a "Run once" agent in the "Which document(s) should it run on?" property.Dim session as new NotesSessionDim db as NotesDatabaseDim view as NotesViewDim doc as NotesDocumentSet db=session.currentdatabaseSet view = db.getview("MyFolder")Set doc = view.getfirstdocumentwhile not doc is Nothing Call doc.removefromfolder("MyFolder") Set doc = view.getfirstdocumentwend>>>>RemoveAllFromFolder Method of R5 NotesViewEntryCollection Class Sometimes FailsProblem:The RemoveAllFromFolder method (of the NotesViewEntryCollection class, new for R5) does not remove all documents from the folder specified. Further observation reveals that this issue occurs with only Categorized folders, but not in all cases.Solution:This issue will occur in cases where the method is applied to a Categorized folder in which some documents are listed more than once. By design, documents which have multiple values in the field used in a categorized column should appear multiple times in the folder. The fact that the RemoveAllFromFolder method does not properly work in this case has been reported to Lotus Quality Engineering.This issue has no effect on the RemoveAllFromFolder method of the NotesDocumentCollection class.Workarounds:1. LotusScript workaround using the RemoveAllFromFolder method:The workaround below will cause the While loop to execute by a factor related (and typically equal) to the maximum number of entries found in the field that the folder is categorized by. So if the maximum number of values found in the field was four then the loop will execute a maximum number of four times. The number of times it loops can be less depending on how many documents have multi-value fields and the number of documents in the folder.Sub Click(Source As Button) Dim s As New notessession Dim folder As notesview Dim foldercollection As notesviewentrycollection Set folder=s.currentdatabase.getview("Categorized Folder") Set foldercollection=folder.allentries While foldercollection.count<>0 Call foldercollection.removeallfromfolder("Categorized Folder") Set foldercollection=folder.allentries WendEnd Sub2. Formula workaround:You could use a Formula which makes use of the @Commands EditSelectAll and RemoveFromFolder. This workaround relies on the folder in question being the currently opened folder. The LotusScript workaround above does not have the same limitation.Example:@Command([EditSelectAll]);@Command([RemoveFromFolder])>>>>>Converting Multiple Mail Files Places All Documents in Inbox as well as the Intended FolderProblem:The Inbox folder in the Mail file displays all documents after the following command is run on the Mail file: load convert mail\*.nsf stdr4mail mail45.ntfSpecifically, this issue occurs after converting the mail file for the second time. (For instance, you have just upgraded a mail file from 4.x to 4.5x, after it was previously upgraded from Notes 3.x.)Once the second conversion has been executed, every document in the mail file is located in the Inbox, as well as the intended folder. In addition, the following entry is listed in the Notes Log file (log.nsf):xx/xx/xx 01:31:53 PM Mail Convert: Opening & repopulating existing folder '$Inbox'Solution:This issue occurs because the Convert utility, when run with the wildcard parameter, automatically converts categories to folders, even when categories were already converted to folders during a previous upgrade. This issue is addressed in Notes 4.5.3.Excerpt from the Notes 4.5.3 Fix List:SPR# DSMH3EUP99, MGRS3L7KHE - Allow the Mail Convert utility to work correctly when run multiple times on a mailfile.With this fix, the Convert utility converts categories to folders ONLY if:1. The old template name and the new template file name are specified AND the database does not contain a ($Inbox) folder.OR2. The -C option is used to force category conversion.Information on which folder a document belongs to is kept within the folder itself. Consequently, it is not possible to determine from a document's properties which folders it is in.Using earlier Notes releases, you can use the following sample script to remove the appropriate documents from the Inbox. The script builds an array of strings that are the UNIDs of documents that are contained in folders other than the Inbox. Then, the loops through the Inbox and compares the UNIDs of those documents to the UNIDs in the array. (The script can be placed in a button and then mailed to the users who need it.)SAMPLE SCRIPT:Sub Click(Source As Button) '************************************************************************************* ' This agent builds a collection of views which are folders, but not the inbox, ' then builds an array which contains the UNID's of all the docs in those folders. ' It then loops through ($Inbox) and compares the UNID of each doc to the values ' in the array, and removes the doc from the inbox if it's in another folder. '************************************************************************************* Dim s As New notessession Dim db As notesdatabase Dim fDoc As NotesDocument ' Doc in folder Dim ib As notesview ' inbox Dim ibDoc As notesdocument ' doc in inbox Dim fUNID() As String ' array of UNID's of docs in folders Dim i As Integer ' UNID array index i =0 Set db = s.CurrentDatabase ' Build UNID array by looping through views, then their docs Forall view In db.views If view.IsFolder And Not view.Name=("($Inbox)") Then Set fDoc = view.GetFirstDocument While Not fDoc Is Nothing Redim Preserve fUNID(i) fUNID(i) = fDoc.UniversalID i=i+1 Set fDoc = view.GetNextDocument(fDoc) Wend End If End Forall ' Loop through docs in the Inbox n = 1 Set ib = db.GetView("($Inbox)") Set ibDoc = ib.GetNthDocument(n) While Not ibDoc Is Nothing ' Check the array to see if it has a match For i = 0 To Ubound(fUNID) If fUNID(i) =ibDoc.UniversalID Then ' if there's a match, remove the doc, then refresh the inbox Call ibDoc.RemoveFromFolder("($Inbox)") Call ib.Refresh ' Since we removed a doc from the view, the next doc ' will have the same position in the view as the previous. ' As the pointer is always incremented in the While, ' we need to decrement it here to keep it the same. n = n-1 ' We can stop checking for any other occurrences of ' this doc as we've already removed it from ($Inbox) Exit For End If Next n=n+1 Set ibDoc = ib.GetNthDocument(n) Wend End Sub
Bien à vous

http://www.dominoarea.org/oguruma/

Les téléphones PORTABLES dans les TGV y en a MARRRE de ces voyageurs qui ne respectent pas les autres ! ARRET DES PORTABLES SVP - Merci

Fumeurs ! respectez les non fumeurs !!!
Fumeurs ! respectez la loi de février 2007 et les lieux publics !!! (ie. hall de gares)
Avatar de l’utilisateur
oguruma
Super V.I.P.
Super V.I.P.
 
Message(s) : 4086
Inscrit(e) le : 16 Déc 2004 à 08:50
Localisation : LILLE

Re: Effacer le contenu d'un folder

Messagepar Seve » 30 Jan 2004 à 09:23

Merci beaucoup pour ces informations... grâce auxquelles je vais pouvoir progresser un peu...Sinon, j'ai trouvé une solution à mon problème, en supprimant tout simplement le folder après utilisation. De toute manière, la méthode PutAllInFolder crée le folder quand il n'existe pas... donc pas de souci.
Seve
 


Retour vers Développement

cron