Domino Code Fragment

Code Name*
Setting values in several documents without opening them depending on a change in a different document
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.144.36.141
Description*
checks docs created with a second form and does a collection depending on a field value then sets the status field of teh collected docs to closed.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:



--------------------------------------------------------------------------------

Dim Sess as New NotesSession
Dim DB as NotesDatabase
Dim MainDoc as NotesDocument
Dim ProcessDoc as NotesDocument


Dim NUIW as New NotesUIWorkspace
Dim NUID as NotesUIDocument


Dim DocNo as String
Dim Search as string
Dim coll as NotesDocumentCollection


'get the current document from the UI classes
Set NUID = NUIW.CurrentDocument
Set MainDoc = NUID.Document


'get the Document number from the doc the user is looking at
DocNo = MainDoc.DocNo(0)


'get this document's database
Set Db = MainDoc.ParentDatabase


'search the current database for all documents with form=Form1 and DocNo1 = this document's DocNo
search$ = "Form = ""Form1"" & @LowerCase(DocNo1) = """ + Lcase$(DocNo) + """"
Set coll = DB.Search(search$, Nothing, 0)


Set ProcessDoc = coll.GetFirstDocument

'If any documents matching search criteria were found, process them
Do While Not Doc Is Nothing
Call ProcessDoc.ReplaceItemValue("Status","Closed")
Call ProcessDoc.Save(True,False)


Set ProcessDoc = coll.GetNextDocument(ProcessDoc)
Loop


'After all other documents are processed make sure this one's status is also changed
Call MainDoc.ReplaceItemValue("Status","Closed")
Call MainDoc.Save(True,False)