I have an application that sends a URL within an email wich will take the user to a document to Edit it. It is real basic. Only two fields to fill in and a submit button that onClick performs the js function signatureValidation().
function isValidDate(indate){
var sdate = indate.split("/");
var chkDate=new Date(Date.parse(indate));
var cmpDate=(chkDate.getMonth()+1)+"/"+(chkDate.getDate())+"/"+(chkDate.getFullYear());
var indate2=(Math.abs(sdate[0]))+"/"+(Math.abs(sdate[1]))+"/"+(Math.abs(sdate[2]));
if (indate2!=cmpDate){
//alert("You must enter a valid date in MM/DD/YYYY format or leave this field blank.");
return false;
} else {
if (cmpDate=="NaN/NaN/NaN"){
//alert("You've entered an invalid date or date format. Please use the MM/DD/YYYY format or leave this field blank.");
return false;
} else return true;
}
}
function validateSignature(){
var form = document.forms[0];
var msg = "";
if (form.applicantSignature.value == "" || form.applicantSignature.value == null){
msg = msg + ("\nYou must input your full name before submitting.");
}
if (form.applicantdob.value == "" || form.applicantdob.value == null) {
msg = msg + ("\n You must input your Date of Birth before submitting.");
}else{
if(!isValidDate(form.applicantdob.value)){
msg= msg + ("\nDate of Birth must be in MM/DD/YYYY format");
}
}
if (msg.length>0){
alert("Please complete the following before submitting:\n"+msg);
} else {
form.submit()
}
}
This validation works without flaw when either or both fields are left blank. When they are filled in and the document is submitted, I get the error.
I have a $$Return field on the form to a new URL. I have also tried it without the $$Return field and used a Print “[HTTP://…]” statement within the WebQuerySave event agent. Well I continuously get an HTTP 500 error when clicking on the submit button but the log shows the “agent has never ran before” prompt. The Default user permission is set to Editor so no Author field is necessary (at least I wouldn’t think so). So from what I can tell, the document (?EditDocument not ?OpenForm) is submitting to itself (because the returned URL has the seq=1 text appended at the end) and never even runs the agent. What the heck am I missing here?
Subject: HTTP 500 Error and submit()
Does the document get saved? I am betting the problem is in WebQuerySave agent. Since the WQS agent is not run by the AgentManager, it will not show when it was last run. Does it run? Add some debug statements to see how far the agent succeeded. It is not unlikley that you are trying to redirect to an invalid URL. Have you checked to see what URL is being calculated? I admit I did not read your JavaScript thoroughly, but I am betting that the problem is on the server side, not browser.
Subject: RE: HTTP 500 Error and submit()
Well, it is kind of hard to run the agent manually since it requires a document for context. At any rate here is my WQS agent (some items have been changed to provide anonominity). I am not sure why I have commented out the save to the document. Can be a problem?:
Sub Initialize
Dim agentLog As New NotesLog("Agent log")
Call agentLog.OpenAgentLog
Call agentLog.LogAction("Action one")
On Error Goto processError
Dim s As New NotesSession
Dim db As NotesDatabase
Dim memo As NotesDocument
Dim rtitem As NotesRichTextItem
Dim subjectText As String
Dim emailto(1 To 2) As String
Dim profileDoc As NotesDocument
Dim currentdoc As NotesDocument
Dim appdoc As NotesDocument
Dim newdoc As NotesDocument
Dim internalDB As NotesDatabase
Dim luApps As NotesView
Dim luView As NotesView
Dim checklistDoc As NotesDocument
Dim Key(1 To 2) As String
Dim Key2(1 To 3) As String
Dim agent As NotesAgent
Set db = s.CurrentDatabase
Set currentdoc = s.DocumentContext
’ currentdoc.Save True, True
'get checklist and update the status of the signed job offer form
Key(1) = currentdoc.ReqNumber(0)
Key(2) = currentdoc.LastName(0)
Key2(1) = currentdoc.ReqNumber(0)
Key2(2) = currentdoc.LastName(0)
Key2(3) = currentdoc.FirstName(0)
Set profileDoc = db.GetProfileDocument("AppProfile")
Set internalDB = s.GetDatabase( profileDoc.IntJobPostingSvrLocation(0), profileDoc.IntJobPostingDBLocation(0) )
Set luView = internalDB.GetView("lookupchecklist")
Set luApps = internalDB.GetView("appsIndex")
Set checklistDoc = luView.GetDocumentByKey(Key, True)
Set appdoc = luApps.GetDocumentByKey(Key2, True)
checklistDoc.CurrentStatus = "Job Offer Accepted"
If checklistDoc.Form(0) = "appChecklistExt" Then
checklistDoc.HistoryStep5 = checklistDoc.HistoryStep5(0) & Chr(10) & Chr(13) & Now() & " - Applicant signed Job Offer."
Else
checklistDoc.HistoryStep6 = checklistDoc.HistoryStep6(0) & Chr(10) & Chr(13) & Now() & " - Applicant signed Job Offer."
End If
checklistDoc.Save True, False
emailto(1) = currentdoc.HRRep(0)
emailto(2) = currentdoc.Manager(0)
Set newdoc = internalDB.CreateDocument
Call currentdoc.CopyAllItems(newdoc, False)
Call newdoc.save (True, False)
Set memo = db.CreateDocument
memo.Form = "Memo"
Set rtitem = New NotesRichTextItem(memo, "Body")
memo.Subject = "Job Offer has been signed by applicant " + currentdoc.ReqNumber(0)
Call rtitem.AddNewLine(2)
Call rtitem.AppendText("Please Click the link below to view the signed Job Offer form.")
Call rtitem.AddNewLine(1)
Call rtitem.AppendDoclink(newdoc, "")
Call rtitem.AddNewLine(2)
Call rtitem.AppendText("Link to subject's application.")
Call rtitem.AddNewLine(1)
Call rtitem.AppendDoclink(appdoc, "")
memo.SendTo = emailto
Call memo.Send( False )
If checklistDoc.Form(0) = "appChecklistExt" Then
'run agent on Internal Posting DB to start background paperwork
Set agent = internalDB.GetAgent("(kickOffBGCheck)")
If agent.Run(appdoc.NoteID) = 0 Then
AgentLog.LogAction("Agent ran")
' update the checklist for this applicant since agent ran
checklistDoc.startPaper = "started"
checklistDoc.HistoryStep6 = checklistDoc.HistoryStep6(0) & Chr(10) & Chr(13) & Now() & " - Paperwork Started: Background Check has been sent to applicant."
checklistDoc.Save True, False
Else
AgentLog.LogAction("Agent did not run")
End If
End If
Goto exitSub
processError:
AgentLog.LogAction( "Error " & Err() & ": " & Error$ & " on line " & Cstr(Erl) )
exitSub:
Call agentLog.Close
Print "[http://www.company.com]"
Exit Sub
End Sub