I have a form for “SAP Request” which has 2 buttons , “ABAP Request” and “Basis Request”.When “ABAP Request” is clicked , a form “ABAP” opens and when “Basis Request” is clicked , a form “Basis” opens.
“SAP Request” form has a field “child_id” which is set whenever “ABAP Request” or “Basis Request” button is clicked.Both of the child forms also has a field “child_id” which is inherited from Parent form.
The code which I use for setting chilld_id whenever “ABAP Request” or “Basis Request” button is clicked is as follows:
Sub Click(Source As Button)
Dim w As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim vc As NotesViewEntryCollection
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim counterdoc As NotesDocument
Dim itemA As NotesItem
Dim notesForm As NotesForm
Dim doc1 As Notesdocument
Dim collection As NotesDocumentCollection
Dim currentResponse As NotesDocument
Dim i As Integer
Set db = session.CurrentDatabase
Set uidoc = w.CurrentDocument
Set doc = uiDoc.Document
Set doc1 = db.CreateDocument
Set collection = doc.Responses
Set currentResponse = collection.GetFirstDocument
i = doc.Responses.Count + 1
Call uidoc.FieldSetText("child_id",uidoc.FieldGetText("id") + " - " + Cstr(i))
Call uidoc.FieldSetText("fd_modified_date",Cstr(doc1.Created))
Call w.ComposeDocument( "", "", "Form" )
Call uidoc.Save
unid = doc.UniversalID
doc.SaveOptions = "0"
Call doc.Save(False, True)
Call uidoc.close
End Sub
Id is the counter of the “SAP Request” form.
The problem which I have is that whenever a new child is created , child_id value should be “id - 1”,and so on but it always shows "id - " when first time “ABAP Request” or “Basis Request” button is clicked.some times , 3rd or 4th child is created but it shows the id value as “id-5”.
2nd problem is that “SAP Request” form has a button “Close Request” which should be enabled only when all child request have been closed.I have “rwfdocstatus” field on both the child forms and I use the following code to check the child request status.if the status is “Request Closed” for all child requests , “Close Request” button is enabled.
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
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
If(check = doc.Responses.Count) Then
Call uidoc.FieldSetText("x_fd_statusN" ,"8.5")
End If
savcheck=1
Call uidoc.Save
unid = doc.UniversalID
doc.SaveOptions = "0"
Call doc.Save(False, True)
Call uidoc.close
End Sub
The issue is that it works properly only when there is no child.If requests have childs , it does not enable “Close Requests” when all child requests have been closed.Some times , it creates another copy of same “SAP Request” and enable “Close Request” button in that copied form.
Kindly tell me what are the issues behind this?
Regards,
Aisha Ishrat.