Problem in agent for child docs

I have a main request form.There is a button on main request form “check”. I have written a code behind the check button which checks for the status of all child docs of main request form and if the status of all child docs is “request closed” , it will change the field value on main request “x_fd_statusN” to 8.5. The code is as follows:

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim collection As NotesDocumentCollection

Dim currentResponse As NotesDocument

Dim i As Integer

Dim check As Integer



Set uidoc = workspace.CurrentDocument

Set doc = uidoc.Document

Set collection = doc.Responses

Set currentResponse = collection.GetFirstDocument



Call doc.PutInFolder( "child docs" )

’ Put immediate responses to doc into the folder

’ If there are none, sub exits and returns to calling sub

check = 0



If(doc.Responses.Count = 0) Then

	Exit Sub

	

Else

	

	

	For i = 1 To doc.Responses.Count

		Call currentResponse.PutInFolder("child docs" )		

		If (currentResponse.rwfdocstatus(0) = "Request Closed")  Then

			check = check + 1 

		End If

		Set currentResponse = collection.GetNextDocument _

		( currentResponse )

	Next

	

	

End If



If(check = doc.Responses.Count) Then

	Call uidoc.FieldSetText("x_fd_statusN" ,"8.5")

End If





unid = doc.UniversalID

doc.SaveOptions = "0"



Call doc.Save(False, True)	

Call uidoc.Refresh

Call uidoc.close

End Sub

The problem is that when value of “x_fd_statusN” is 8.5 set by the above code , a button should be displayed “close functional request” which is hidden if “x_fd_statusN” is not 8.5.

The issue is that this code does not change the status of the field and button is not displayed.

Could any one please tell that why this code is not working?

Thanks.

Subject: problem in agent for child docs

The following lines could be the problem -

If(check = doc.Responses.Count) Then

Call uidoc.FieldSetText(“x_fd_statusN” ,“8.5”)

End If

This condition will be true only if the check (count) is qeuql to responses count.

Check is increated by -

If (currentResponse.rwfdocstatus(0) = “Request Closed”) Then

check = check + 1

End If

So, the value of “rwfdocstatus” field of response document may not be equal to “Request close” for every document.

The above code only works when the rwrdocstatus field value of every response document is equal to “Request Closed”.

Hope so you got it.

–Phani

Subject: RE: problem in agent for child docs

yes , its right.The value of “rwfdocstatus” is not “Request Closed” for every response document and I want to enable the button “close main request” on main form when all child requests have been closed.

whenever it finds that the status of child request is “Request closed” , it increments the value of check by 1 so that if all child requests have statuses “Request closed” , the value of check should be equal to the total no of response documents i.e. doc.responses.count and only then the status on main form should be 8.5.

cant figue out why it doesnt work.

Subject: RE: problem in agent for child docs

What is the hide when formula you have written for the button.

–Phani

Subject: RE: problem in agent for child docs

x_fd_statusN!=8.5

Subject: RE: problem in agent for child docs

Hi Aisha,

The hide-when formula should be

x_fd_statusN!=“8.5”

(you put a text-value in the x_fd_statusN field)

Regards,

René

Subject: RE: problem in agent for child docs

no Rene,

This is not the issue, I have set statuses like that in almost every form and it works.