Whist setting the last status to “Complete” on a web doc, I need to check if no response docs are available in statuses other than “Complete”. BTW - both responses and main doc have can have status = “Complete”.If there are any I want to display an error message and focus on the opened document without changing the status.
If there aren’t any, I want to save the document with the new status.
I change the status on the main document by using a button containing:
frm.status.value=“Complete”;
frm.submit();
The agent that runs on WebQuerySave does the following:
Dim sess As New NotesSession
Dim doc As NotesDocument
Dim db As NotesDatabase
Set db = sess.CurrentDatabase
Set doc = sess.DocumentContext
Dim server As String, path As String, status As String, send_to As String, new_flag As String, UNID As String
server = doc.Server_Name(0)
path = doc.DBPath(0)
status = doc.status(0)
UNID = doc.UniversalID
If status = “Complete” Then
key = "formname = ""action"" & incidentno = "+doc.incidentno(0)+""
Set coll = db.Search(key, Nothing, 0)
If coll.Count = 0 Then
Print "... coll.Count = 0 ..."
'run function that releases the document (parameter = doc)
Call release_doc(doc, UNID) ' function that releases the lock document
Call savedoc(doc) ' subroutine'
End If
Set actiondoc = coll.GetFirstDocument
Do Until actiondoc Is Nothing
If actiondoc.status(0) = "Complete" Then
'get next
Goto getnext
End If
If actiondoc.status(0) <> "Complete" Then
doc.status(0) = "Close Out" ' reverting to previous status - the current one was set in the button
Print {<Script>}
Print {alert('}+"This incident has related actions that are not completed. The incident cannot be marked as complete until all the actions are completed."+{');}
Print {closeDoc();}
'' reload document - no other changes needed
Print {window.location.reload();}
Print {</SCRIPT>}
Goto endithere
End If
getnext:
Set actiondoc = coll.GetNextDocument(actiondoc)
Loop
End If
End If
carryon:
Set doc = set_perms(doc) ’ function that sets authors and readers field base on status’
'redirect the browser back to the opening frameset - actions only
Print {}
End If
endithere:
Exit Sub
Sub savedoc(doc As NotesDocument)
Print {<SCRIPT>}
Print {window.location.replace('}+"http://" + doc.server_name(0) + "/" + doc.DBPath(0) + "/main?OpenFrameset" + {');}
Print {</SCRIPT>}
End Sub
The problem is that the response documents are not seen at all by this code. My guess is that it has something to do with the way submit works and at which time the doc is actually saved…
What would an efficient way of doing this be?
Basically, on the web, I want to update the status of the current doc and reload the frameset if the document does not have responses with the status = “Completed”. If it has, I want to display an error and revert to the original document.
Thank you