Search code examples
lotus-noteslotus-dominolotusscript

Lotus scripts Set value(Unique Number) in each document from GetAllDocumentsByKey


From my code below try to Looping from "GetAllDocumentbyKey" and Set Unique number each document for to show in Folder View , but from my code it's not work. How should I solve this problem?

Dim defect As Variant
defect = uidoc.FieldGetText("DefectMode")
keys( 0 ) =defect
Dim PartNo As Variant
partNo = uidoc.FieldGetText("PartNo")
keys( 1 ) = partNo

Set view = db.GetView("EmbedView2" )

Set dc = view.GetAllDocumentsByKey(keys,False)
Call dc.PutAllInFolder("EmbedFolder")

Do Until dc Is Nothing
    call uidoc.FieldSetText("UniqueNo","number") // this code I try to set unique number to each document by number that's I plan to increase 1 , I have to set in "UniqueNo" Fieled
Loop

Solution

  • OK... There is a big part missing from your code.

    uidoc is the currently open document and if I guess right, it has an embedded view in it called "EmbedFolder". The documents you want to modify all belong to a special DefectMode and a special PartNo (that of the currently open document)

    I doubt that what you want makes sense, but I don't wanna go into that.

    To make your code work you need to cycle through the document collection and set each documents value separately. This would simply look like this:

    Dim intNumber as Integer
    Dim doc as NotesDocument
    intNumber = 1
    Set doc = dc.GetFirstDocument()
    Do until doc is Nothing
      Call doc.ReplaceItemValue( "UniqueNo" , intNumber )
      Call doc.Save( True, True, True )
      Set doc = dc.GetNextDocument( doc )
    Wend