My LS Loop Not Looping?

Hello all,I have a notes db similar to a discussion db. Has main docs and response docs.

But the customer wanted readers fields on them, certain ppl to see yadda yadda.

So I have a query save script running to update response docs, if there are any.

Here’s the problem: when saving the document, and the notes clients are 6.5.3, it is locking up their notes client. The document is getting saved, but its like its not ending a function or something, which makes me believe that my LS loop is screwy.

6.5.1 clients are fine. I have ruled out WAN and everything else and have come to the conclusion that it is my coding.

Could someone have a peek and correct me? i’m searching forums right now and will report back if I find anything. I have been searching for awhile now, that’s why i’m posting.

THANKS ANYONE!

******** START CODE **********

Sub Querysave(Source As Notesuidocument, Continue As Variant)

  'Access the Parent DocID field from current UI Doc

 'This DocID field contains the @Text(UniqueUnivesalID) data

 'This returns the UNID as a string from the DocID field

 'Variable ResponseDocID will be this @Text(UNID)

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim ParentDocID As String

Set uidoc = workspace.CurrentDocument

ParentDocID = uidoc.FieldGetText( "MainID" )

 'Access View that contains all response forms

Dim session As NotesSession

Dim db As NotesDatabase

Dim view As Notesview

Dim doc As NotesDocument

Dim nextdoc As NotesDocument

Dim item As NotesItem

Dim ReadN As notesitem, AuthN As notesitem

Dim ReaderNames As NotesItem, AuthorNames As NotesItem



Set session = New NotesSession

Set db = Session.CurrentDatabase

Set view = db.GetView("$ResponseRequestLookup")

Set doc = View.GetFirstdocument

Set ReadN = uidoc.Document.GetFirstItem("ReaderNames")

Set AuthN = uidoc.Document.GetFirstItem("AuthorNames")



 ' Each Doc has the same DocID as the Response docs

 ' Now we look at each response doc and get the value DocID field

 ' Compare DocID field from parent to the DocID of the response

 ' If they are equal, then the response docs change automatically

While Not (doc Is Nothing)

	ResponseDocID = doc.GetItemValue("DocID")

	OldRN = doc.GetItemValue("ReaderNames")

	OldAN = doc.GetItemValue("AuthorNames")

	If ParentDocID = ResponseDocID(0)  Then

		ReadN.IsReaders=True

		AuthN.IsAuthors=True

		Call doc.replaceitemvalue("ReaderNames",ReadN.values)

		Call doc.replaceitemvalue("AuthorNames",AuthN.values)

		

		

		Call doc.Save( True, True )

		

	End If

	Set nextdoc = view.getnextdocument(doc)

	Set doc = nextdoc

Wend

End Sub

************ end code ********

Subject: My LS Loop Not Looping?

I’m not sure it will solve your problem, but you should move

Set nextdoc = view.getnextdocument(doc)

up to right before

ResponseDocID = doc.GetItemValue(“DocID”)

Subject: My LS Loop Not Looping?

Chris,

have you considered moving this line:

set nextdoc = view.getnextdocument(doc)

to the beginning of your While loop? It could be that when you add the readers field to the existing doc you are removing it from the “$ResponseRequestLookup” field (especially if the effective user or server don’t have read access.) I wonder if by getting a handle on the next doc before you do your processing if it would solve your issues. From where I sit, if that is the case, it shouldn’t work in 6.5.1 or 6.5.3 to be honest.

hth.

brandt

Subject: My LS Loop Not Looping?

Oh man, thank you so much!

I fixed and am awaiting my user to try. I will report back with results.