Submit Is Not Saving The Document

This is wierd I am calling simple javascript and it is not working… Below is my code… It does all the javascript fine and submits but in the Web Query Save agent when I try to reference the field approverFlag it has the wrong value compared to what I put in it before I submited… Any ideas?

if (document.getElementById('grandTotal').value == 0){

	strFARType = "Please enter the reason you are rejecting this Service Request...";

} else {

	strFARType = "Please enter the reason you are rejecting this FAR...";

}

	var rejectBecause=prompt(strFARType,"");

if (rejectBecause != null && rejectBecause != "") {

		document.getElementById('rejectReason').value = rejectBecause;

		document.getElementById('approverFlag').value='reject0'+num;

		document.forms[0].submit();

}else{

		alert ("You Must Enter A Reson For Rejecting The Far")

}

Subject: Submit Is Not Saving The Document

What value are you getting? Can you post the WQS agent code?

If you remove the WQS part from the equation, does the form at least save with the intended resultant value in the field?

More details, and we’ll help ya out!

-Chris

Subject: RE: Submit Is Not Saving The Document

(Working with Chris on this issue) - Sorry this is going to be so long. Basically we have our Request form which has an approval subform on it. If the user has the Edit role that means they can edit or over-ride approve at any level. After submission and level 1 approves the form becomes locked except for the approval buttons without that role. If we give ourselves the edit role and have 4 levels of approval everything works fine we get a stage of 1 through 4 accordingly then it goes to stage 6 which is the technician. If we remove the edit role we get stage 1 listed at every stage even though a JS alert shows 1 through 3 and at level 3 when you approve it then moves you back to level 1.

*Code Pasted In

Here is the WQS Code - (Not putting all extra subs just the ones I think you may want to see, if you need another one just let me know)

Sub Initialize

(Delcarations…) [To save space]

'Used in setting Client Services Approvers

Set nam = s.CreateName(s.EffectiveUserName)

Set currDb = s.currentDatabase

Set currDoc = s.DocumentContext

currDoc.RemoveItem(“txtUserHasEditAccess”)

server = currDb.Server

path = “/” & fixStringForURL$(currDb.FilePath) & “/”

cost = currDoc.grandTotal(0)

Set routeDb = New NotesDatabase(server, “Names.nsf”)

Set adminDb = New NotesDatabase(server, “far\farAdmin.nsf”)

Set routingVw = adminDb.GetView(“vwFarRoutingLU”)

Set vwCSContacts = adminDB.GetView(“vwCSDeptContacts”)

Set assDate = New NotesDateTime( currDoc.DateAssigned(0) )

routingDocCnt = routingVw.EntryCount

If currDoc.approverFlag(0) =“sendBack” Then

'###Need to deal with this.

Else

'Check to see whether this is a FAR Reqeust or Service Reqeust.

If currDoc.FARType(0) = "Service Request" Then

  'Means we have executed the following block of code already so can skip it.

Else

  If currDoc.approverFlag(0) = "draft"  Then

    'do nothing, as we are in draft mode.

  Else

    If currDoc.grandTotal(0) = 0 Then

      'Need to validate Comments Field.  If grandTotal is 0 and there are no items then comments is required.

      'However, if grandTotal is 0 but there are items chosen then comments are not needed.

      currDoc.FARType = "Service Request"

      currDoc.approverFlag = "serviceRequest"

   Else

     currDoc.FARType = "Fixed Asset Request"

   End If

End If

End If

End If

Select Case currDoc.approverFlag(0)

Case “preSubmit”

currDoc.FARStatus = "Department Change"

mailDocSendTo = "Steven Cannon"

mailDocFrom = currDoc.Author(0)

mailDocSubject = "This FAR has been charged to a department ID other than the requested for's."

mailDocHrefText = "Make the necessary changes to this FAR to ensure correct routing for the department ID that is being requested to be used.  You will set the DeptID, Business Unit and Location field as required.  You must then press the Approve for Routing button to reset the routing and to begin the approval process."

mailDocURL = path + "0/" + currDoc.UniversalID

Call MimeMailer(mailDocSendTo, "", mailDocSubject, maildocURL, mailDocHrefText, mailDocFrom)

Case “draft”

currDoc.FARStatus = "Draft"

currDoc.DisplayFARStatus = "Draft"

Case “serviceRequest”

currDoc.FARStatus = "Service Request Submitted"

currDoc.DisplayFARStatus = "Service Request Submitted"

Call SetNumber(adminDb, currDoc)

'Need to send a mail to the CS Dept Contact for the Deptartment on the Request.

tmpDept = currDoc.FARDept(0)

Set docCSContact = vwCSContacts.GetDocumentByKey(tmpDept)

mailDocSendTo = docCSContact.GetItemValue("CSDeptContact")

mailDocSubject = " A Service Request has been submitted."

mailDocURL = path + "0/" + currDoc.UniversalID

mailDocFrom = currDoc.Author(0)

mailDocHrefText = "Please review the following Service Request and approve or reject/Cancel. "

Call MimeMailer(maildocSendTo, "", mailDocSubject, mailDocURL, mailDocHrefText, mailDocFrom)

If currDoc.ReviewSignature(0) = "" Then

	currDoc.ReviewSignature = nam.Common

	currDoc.ReviewDate = Now

End If

currDoc.Route6 = mailDocSendTo

currDoc.Title6 = "Client Services Contact"

currDoc.txtTechFlag = "Y"

currDoc.CCDate = Now	

Case “submit”

'set routing steps from routing profiles

If currDoc.RoutingSet(0) <> "ApprovedFAR" Then

                            If(currDoc.DIDCorrect(0)="" Or currDoc.DIDCorrect(0)="Yes" ) Then 

                RoutingKeyCust = Trim(Cstr(currDoc.BusinessUnit(0) + currDoc.DeptID(0) + currDoc.Location(0) + currDoc.Customer(0)))

	RoutingKeyLoc =  Trim(Cstr(currDoc.BusinessUnit(0) + currDoc.DeptID(0) + currDoc.Location(0)))

			RoutingKeyDept = Trim(Cstr(currDoc.BusinessUnit(0) + currDoc.DeptID(0)))

			RoutingKeyBU = Trim(Cstr(currDoc.BusinessUnit(0)))

		Else

			RoutingKeyCust = Trim(Cstr(currDoc.BusinessUnitC(0) + currDoc.DeptIDC(0) + currDoc.LocationC(0) + currDoc.CustomerC(0)))

			RoutingKeyLoc =  Trim(Cstr(currDoc.BusinessUnitC(0) + currDoc.DeptIDC(0) + currDoc.LocationC(0)))

			RoutingKeyDept = Trim(Cstr(currDoc.BusinessUnitC(0) + currDoc.DeptIDC(0)))

			RoutingKeyBU = Trim(Cstr(currDoc.BusinessUnitC(0)))

		End If

		currDoc.Route1 = ""

		currDoc.Title1 = ""

		currDoc.Route2 = ""

		currDoc.Title2 = ""

		currDoc.Route3 = ""

		currDoc.Title3 = ""

		currDoc.Route4 = ""

		currDoc.Title4 = ""

		currDoc.Route5 = ""

		currDoc.Title5 = ""

	End If

	

	'Get the routing document for this process.

	Dim strProfileName As String	

	For x = 1 To 5

		Select Case x

		Case 1

			strProfileName = RoutingKeyCust

		Case 2

			strProfileName = RoutingKeyLoc

		Case 3

			strProfileName = RoutingKeyDept

		Case 4

			strProfileName = RoutingKeyBU

		Case 5

			strProfileName = "Default"

		End Select

		Set routingDoc = routingVw.GetDocumentByKey(strProfileName,True)

		If Not routingDoc Is Nothing Then

			Messagebox "Got It With:" + strProfileName +"!"

			Exit For

		Else

			Messagebox strProfileName + " is crap!"

		End If

	Next

	

	If cost < 500 Then

		cost = 500

	Elseif cost < 1000 Then

		cost = 1000

	Elseif cost < 2500 Then

		cost = 2500

	Elseif cost < 5000 Then

		cost = 5000

	Else

		cost = 5001

	End If

	If routingDoc.BusUnit(0) <> "DEFAULT" Then

		Select Case cost

		Case  500 :

			routingstep = routingDoc.FiveCLimit(0) 

			routingtype = routingDoc.RouteTypeLimit1(0)

		Case  1000 :

			routingstep = routingDoc.OneKLimit(0)

			routingtype = routingDoc.RouteTypeLimit2(0)

		Case  2500 :

			routingstep = routingDoc.TwoKLimit(0)

			routingtype = routingDoc.RouteTypeLimit3(0)

		Case  5000 :

			routingstep = routingDoc.FiveKLimit(0)

			routingtype = routingDoc.RouteTypeLimit4(0)

		Case  5001 :

			routingstep = routingDoc.OverFiveKLimit(0)

			routingtype = routingDoc.RouteTypeLimit5(0)

		End Select

	Else ' if it = "DEFAULT"

		Select Case cost

		Case 500 :

			routingstep = routingDoc.FCLBook(0) 

			routingtype = routingDoc.RouteTypeLimit1(0)

		Case  1000 :

			routingstep = routingDoc.OKLBook(0)

			routingtype = routingDoc.RouteTypeLimit2(0)

		Case 2500 :

			routingstep = routingDoc.TKLBook(0)

			routingtype = routingDoc.RouteTypeLimit3(0)

		Case 5000 :

			routingstep = routingDoc.FKLBook(0)

			routingtype = routingDoc.RouteTypeLimit4(0)

		Case 5001 :

			routingstep = routingDoc.OFKLBook(0)

			routingtype = routingDoc.RouteTypeLimit5(0)

		End Select

	End If

	Set routeVw = routeDb.GetView("($Users)") ' this is the view to check if group or person

	

	If Not(routingDoc Is Nothing) Then

		'1st Approver

		If routingDoc.CC1(0) = "Yes" Then

			currDoc.CC1 = "Yes" 

			currDoc.Route1 = currDoc.txtCostCenterApprover(0)

			currDoc.Title1 = currDoc.txtStep1Title(0)

		Else

			currDoc.Route1 = currDoc.txtStep1LUcheck(0)

			currDoc.Title1 = currDoc.txtStep1Title(0)

		End If

		'2nd Approver

		If routingDoc.CC2(0) = "Yes" Then

			currDoc.CC2 = "Yes" 

			currDoc.Route2 = currDoc.txtCostCenterApprover(0)

			currDoc.Title2 = currDoc.txtStep2Title(0)

		Else

			currDoc.Route2 = currDoc.txtStep2LUcheck(0)

			currDoc.Title2 = currDoc.txtStep2Title(0)

		End If

		'3rd Approver

		If routingDoc.CC3(0) = "Yes" Then

			currDoc.CC3 = "Yes" 

			currDoc.Route3 = currDoc.txtCostCenterApprover(0)

			currDoc.Title3 = currDoc.txtStep3Title(0)

		Else

			currDoc.Route3 = currDoc.txtStep3LUcheck(0)

			currDoc.Title3 = currDoc.txtStep3Title(0)

		End If

		'4th Approver

		If routingDoc.CC4(0) = "Yes" Then

			currDoc.CC4 = "Yes" 

			currDoc.Route4 = currDoc.txtCostCenterApprover(0)

			currDoc.Title4 = currDoc.txtStep4Title(0)

		Else

			currDoc.Route4 = currDoc.txtStep4LUcheck(0)

			currDoc.Title4 = currDoc.txtStep4Title(0)

		End If

		'5th Aprrover

		If routingDoc.CC5(0) = "Yes" Then

			currDoc.CC5 = "Yes" 

			currDoc.Route5 = currDoc.txtCostCenterApprover(0)

			currDoc.Title5 = currDoc.txtStep5Title(0)

		Else

			currDoc.Route5 = currDoc.txtStep5LUcheck(0)

			currDoc.Title5 = currDoc.txtStep5Title(0)

		End If

	End If

	'Set up the Client Services Approvers for when it gets there.

	currDoc.CC6 = "No"

	currDoc.Title6 = "Technician"

	Set itemCSApprovers = currDoc.ReplaceItemValue("Route6", currDoc.GetItemValue("FARCSContactLookup"))

	

	'If Dept ID is not correct then need to send a notification.

	mailDocFrom = currDoc.Author(0)

	mailDocURL = path + "0/" + currDoc.UniversalID

	If currDoc.DeptIDC(0) = "" And currDoc.RoutingSet(0) = "" Then

		mailDocSendTo = currDoc.Route1(0)

		mailDocSubject =  currDoc.Author(0)  +  " requests that you review the following FAR"

		mailDocHrefText = "Please review the following FAR and approve or reject."

	Elseif currDoc.DeptIDC(0) = "" And currDoc.RoutingSet(0) = "ApprovedFAR" Then

		mailDocSendTo = currDoc.Route1(0)

		mailDocSubject =  currDoc.Author(0)  +  " requests that you review the following FAR"

		mailDocHrefText = "Please review the following FAR and approve or reject."

	Elseif  currDoc.DeptIDC(0) <> "" And currDoc.RoutingSet(0) = "" Then	

		mailDocSendTo = currDoc.Route1(0)

		mailDocSubject =  currDoc.Author(0)  +  " requests that you review the following FAR"

		mailDocHrefText = "Please review the following FAR and approve or reject."

	Elseif  currDoc.DeptIDC(0) <> "" And currDoc.RoutingSet(0) = "ApprovedFAR" Then

		mailDocSendTo = currDoc.Route1(0)

		mailDocSubject =  currDoc.Author(0)  +  " requests that you review the following FAR"

		mailDocHrefText = "Please review the following FAR and approve or reject."

	End If

	Call MimeMailer(mailDocSendTo, mailDocCopyTo, mailDocSubject, maildocURL, mailDocHrefText, mailDocFrom)

	If currDoc.ReviewSignature(0) = "" Then

		currDoc.ReviewSignature = nam.Common

		currDoc.ReviewDate = Now

	End If

	currDoc.FARStatus = "Waiting on Approval"

	currDoc.AssignedTo = currDoc.Route1(0)

	currDoc.AssignedDate = Now

	currDoc.PrevRoutingKey = RoutingKey

	currDoc.RoutingSet = "ApprovedRequestor"

	Call SetNumber(adminDb, currDoc)

	

Case "sendBack"

	currDoc.CSContactSignature = ""

	currDoc.CSContactDate = ""

	currDoc.VPSignature = ""

	currDoc.VPDate = ""

	

	If (currdoc.RequestorSignature(0) <> "") Then

		currDoc.assigned = currDoc.MailToManager

	Else

		currDoc.assigned = currDoc.ReviewSignaure

	End If

	

	currDoc.DateAssigned = Now

	currDoc.FARStatus = "Send Back for ReApproval"

	currDoc.SendBackFlag = "Yes"

	currDoc.RoutingSet = ""

	currDoc.ReApprovalReason = myImplosionScript(currDoc.ReApprovalReason, ";") + ";" + currDoc.sendBackReason(0)  + " --- " + nam.Common + " " + Cstr(Now)

	For x = 1 To 6

		Call currDoc.ReplaceItemValue("ReviewSignature" + Cstr(x),"")

		Call currDoc.ReplaceItemValue("ReviewDate" + Cstr(x),"")

	Next

	maildocURL = path + "0/" + currDoc.UniversalID

	mailDocSubject = nam.Common + " has sent you the following FAR for Routing"

	mailDocHrefText = "Reason for sending back:  " + currDoc.sendBackReason(0) + "  --->"

	mailDocFrom = nam.Common

	Call MimeMailer(currDoc.ReviewSignature(0), "", mailDocSubject, maildocURL, mailDocHrefText, mailDocFrom)

	currDoc.ReviewSignature(0) = ""

	currDoc.ReviewDate(0) = ""

	currDoc.MailToManager = ""

Case Else

	Dim inStageNum As Integer

	appFlag = Mid(currDoc.approverFlag(0),1,Len(currDoc.approverFlag(0)) -2 )

	

	If Isnumeric(Mid(currDoc.approverFlag(0),Len(currDoc.approverFlag(0)) -1, Len(currDoc.approverFlag(0)) )) Then

		inStageNum = Cint(Mid(currDoc.approverFlag(0),Len(currDoc.approverFlag(0)) -1, Len(currDoc.approverFlag(0)) ))			

	Else 

		inStageNum = 0

	End If

	Messagebox currDoc.approverFlag(0)

	Messagebox appFlag

	Messagebox "StageNum:"+ Cstr(inStageNum)

	If  appFlag = "approve" And inStageNum <> 0 Then

		Call ApproveStage(inStageNum,currDoc,nam)

	Elseif  appFlag = "reject" And inStageNum <> 0 Then

		Call RejectStage(inStageNum,currDoc,nam)

	Else

		Print {<script language="JavaScript">}

		Print {alert('There was an error trying to save your document please go back and try again.  If you repeatedly get this error please contact the help desk.')}

		Print {history.go(-1)}

		Print {</script>}

		Goto getOut

	End If

End Select

thankYou:

'save and thank the user

Call currDoc.save( True, True )

Dim projPath As String

projPath = "/far/farProjects.nsf/"

If currDoc.FARType(0) = "Service Request" Then

	Print {<script language="JavaScript">}

	If inStageNum = 6 Then

		'means we want to auto open the Project Document.

		Print {window.open("}+projPath + {0/} + currDoc.txtProjectDocUNID(0) +  {?OpenDocument","_self");}

	Else

		Print {window.open("} + path + {pgThanks2?OpenPage","_self");}

	End If

	Print {</script>}

Else

	Print {<script language="JavaScript">}

	If inStageNum = 6 Then

		'means we want to auto open the Project Document.

		Messagebox "Auto Open Project Document"

		Print {window.open("}+projPath + {0/} + currDoc.txtProjectDocUNID(0) +  {?OpenDocument","_self");}

	Else

		Print {window.open("} + path + {pgThanks?OpenPage","_self");}

	End If

	Print {</script>}

End If

getOut:

Exit Sub

errHandler:

Print "Error" & Str(Err) & ": " & Error$ & " at line " & Erl

currDoc.deleteThisDoc = "Yes"

Resume getOut

End 

End Sub

Sub ApproveStage(inStageNum As Integer,currDoc As NotesDocument,nam As NotesName)

On Error Goto ErrorHandler

Dim mailDocSendTo As Variant

Dim mailDocCopyTo As Variant

Dim mailDocFrom As String

Dim mailDocSubject As String

Dim mailDocURL As String

Dim mailDocHrefText As String	

Dim stepNum As String

Dim nextStepNum As String

Dim afternextStepNum As String



stepNum  = Cstr(inStageNum)

nextStepNum  = Cstr(inStageNum + 1)

afterNextStepNum  = Cstr(inStageNum + 2)



currDoc. SendInstallFlag = ""

currDoc.IsaLaptop = ""

If (nam.Common = currDoc.GetItemValue("Route" + nextStepNum)(0)) Then

	Call currDoc.ReplaceItemValue("ReviewSignature"+ nextStepNum,Cstr(nam.Common))

	Call currDoc.ReplaceItemValue("ReviewDate"+ nextStepNum,Cstr(Now))

	currdoc.CCDate = Now

	If currDoc.HasItem("Route" + afterNextStepNum) Then

		currDoc.AssignedTo = currDoc.GetItemValue("Route" + afterNextStepNum)(0)

	End If

	currDoc.DateAssigned = Now

Elseif currDoc.HasItem("Route" + nextStepNum) Then		

	If (currDoc.GetItemValue("Route" + nextStepNum)(0) = "") Then

		currDoc.AssignedTo = ""

		currDoc.DateAssigned = ""

	Else

		currDoc.AssignedTo = currDoc.GetItemValue("Route" + nextStepNum)(0)

		currDoc.DateAssigned = Now

	End If

	Call currDoc.ReplaceItemValue("ReviewSignature"+ nextStepNum,"")

	Call currDoc.ReplaceItemValue("ReviewDate"+ nextStepNum,"")

End If



Call currDoc.ReplaceItemValue("ReviewSignature"+ stepNum,Cstr(nam.Common))

Call currDoc.ReplaceItemValue("ReviewDate"+ stepNum,Cstr(Now))



If( currDoc.GetItemValue("CC" + stepNum)(0) <> "Yes" & currDoc.GetItemValue("Route" + nextStepNum)(0) <> "" & currDoc.GetItemValue("Route" + stepNum)(0) <> currDoc.GetItemValue("Route" + nextStepNum)(0)) Then

	currDoc.FARStatus = "Waiting on Approval"

Elseif (nam.Common = currDoc.GetItemValue("Route" + nextStepNum)(0)) Then

	currDoc.FARStatus = "Waiting on Approval"

Else

	currDoc.FARStatus = "On Hold/Order"

End If 

'email the peeps

'Is Cost Center Approver - Close out and Move to Techs.

If currDoc.GetItemValue("CC" + stepNum)(0) = "Yes" Then

	currDoc.FARStatus = "Waiting on IS"

	currDoc.StartTime = Now

	currDoc.txtTechFlag = "Y"

	currdoc.CCDate = Now

	'Mail to Technician

	mailDocSubject = "A new " + currDoc.FARDept(0) + " FAR  for " + currDoc.FARReqFor(0) + " has been approved"

	maildocURL = path + "0/" + currDoc.UniversalID

	mailDocHrefText = "The following FAR has been approved by an authorized approver for cost center .... "

	mailDocFrom = nam.Common

	Call MimeMailer(currDoc.GetItemValue("FARCSContactLookup"), mailDocCopyTo, mailDocSubject, maildocURL, mailDocHrefText, mailDocFrom)

	Call CheckForSecurityRequest(currDoc)

Else		

	If (nam.Common <> currDoc.GetItemValue("Route" + nextStepNum)(0)) Then

		If currDoc.GetItemValue("Route" + nextStepNum)(0) <> "" Then 

			mailDocSubject = currDoc.ReviewSignature(0) +  " requests that you review the following FAR"

			maildocURL = path + "0/" + currDoc.UniversalID

			mailDocHrefText = "The following FAR has been approved by " + nam.Common + " .... "

			mailDocFrom = nam.Common

			Call MimeMailer(currDoc.GetItemValue("Route" + nextStepNum)(0), mailDocCopyTo, mailDocSubject, maildocURL, mailDocHrefText, mailDocFrom)

		End If

		mailDocFrom = nam.Common		

		mailDocSubject = "Your FAR for " + currDoc.FARReqFor(0) +" has been approved by "+ currDoc.GetItemValue("ReviewSignature" + stepNum)(0) + " -- " + currDoc.GetItemValue("Title" + stepNum)(0)

		mailDocURL = path + "/0/" + currDoc.UniversalID

		If(currDoc.GetItemValue("Route" + nextStepNum)(0) <> "") Then

			mailDocHrefText = "This FAR has been routed to Step"+nextStepNum+" .... "

		Else 

			mailDocHrefText = "This FAR has completed all routing steps."

		End If

		Call MimeMailer(currDoc.Author(0), mailDocCopyTo, mailDocSubject, maildocURL, mailDocHrefText, mailDocFrom)

		

	Else 'Approver 1 & 2 are the same & Approver 2 is listed as a Cost Center Approver.  Close out approval and move to technicians.

		If currDoc.GetItemValue("CC" + nextStepNum)(0) = "Yes" Then

			currDoc.StartTime = Now

			currDoc.FARStatus = "Waiting on IS"

			currDoc.txtTechFlag = "Y"

			currdoc.CCDate = Now

			mailDocSubject = "A new " + currDoc.FARDept(0) + " FAR  for " + currDoc.FARReqFor(0) + " has been approved"

			maildocURL = path + "0/" + currDoc.UniversalID

			mailDocHrefText = "The following FAR has been approved by an authorized approver for cost center .... "

			mailDocFrom = nam.Common

			Call MimeMailer(currDoc.GetItemValue("FARCSContactLookup"), mailDocCopyTo, mailDocSubject, maildocURL, mailDocHrefText, mailDocFrom)

			Call CheckForSecurityRequest(currDoc)

		Else	

			currDoc.FARStatus = "Waiting on Approval"

			mailDocSubject = currDoc.ReviewSignature(0) +  " requests that you review the following FAR"

			maildocURL = path + "0/" + currDoc.UniversalID

			mailDocHrefText = "The following FAR has been approved by " + nam.Common + " .... "

			mailDocFrom = nam.Common

			Call MimeMailer(currDoc.GetItemValue("Route" + afterNextStepNum)(0), mailDocCopyTo, mailDocSubject, maildocURL, mailDocHrefText, mailDocFrom)

		End If

		

		mailDocFrom = nam.Common		

		mailDocSubject = "Your FAR for " + currDoc.FARReqFor(0) +" has been approved by "+ currDoc.GetItemValue("ReviewSignature" + nextStepNum)(0) + " -- " + currDoc.GetItemValue("Title" + nextStepNum)(0)

		mailDocURL = path + "0/" + currDoc.UniversalID

		If(currDoc.GetItemValue("Route" + afterNextStepNum)(0) <> "") Then

			mailDocHrefText = "This FAR has been routed to Step"+nextStepNum+" .... "

		Else 

			mailDocHrefText = "This FAR has completed all routing steps."

		End If

		Call MimeMailer(currDoc.Author(0), mailDocCopyTo, mailDocSubject, maildocURL, mailDocHrefText, mailDocFrom)

	End If

End If

If inStageNum = 6 Then

	'Need to check and see if this is a Sent Back for ReApproval first.

	'If it is then need to unlock the Project(s) and Task(s) associated with it and update them.

	currDoc.FARStatus = "Work in Progress"

	currDoc.FARProjInstallDate = getProjectedInstallDate(currdoc, adminDB)

	currDoc.txtProjInstallFlag = "Y"

	If currDoc.txtProjectSendBackFlag(0) = "Y" Then

		'No Need to create a project.

		'Need to unlock the Project & Tasks.

		currDoc.SendBackReason = ""

		currDoc.txtProjectSendBackFlag = ""

		Call UnlockProjects(currDoc)

	Else

		currDoc.txtProjectDocUNID = createProject(currDoc)

	End If

End If

Exit Sub

ErrorHandler:

Call WriteLog("FAR System 2.0 - agtFarWQS - ApproveStage - Line " + Cstr(Erl))

Call WriteLog("ErrorNum - " + Str(Err))

Call WriteLog("ErrorString - " + Error$)

Call WriteLog("ErrorLocation - " + Cstr(Erl))

Call SendLogMailOnly("Steven Cannon")	

Exit Sub

End Sub

Sub RejectStage(inStageNum As Integer,currDoc As NotesDocument,nam As NotesName)

Dim mailDocSendTo As Variant

Dim mailDocFrom As String

Dim mailDocSubject As String

Dim mailDocURL As String

Dim mailDocHrefText As String

Dim mailDocCopyTo As Variant



Dim stageNum As String

stageNum = Cstr(inStageNum)

If stageNum <> "99" Then

	If stageNum <> "6" Then

		If(currDoc.ManagerReject(0) = "") Then

			Call currDoc.ReplaceItemValue("SignatureReject" + StageNum,nam.Common)

		Else

			Call currDoc.ReplaceItemValue("SignatureReject" + StageNum,currDoc.Reject(0) & ":" & nam.Common)

		End If

	Else

		Call currDoc.ReplaceItemValue("SignatureReject" + StageNum,nam.Common)

		currDoc.txtTechFlag = "N"

	End If

	

	Call currDoc.ReplaceItemValue("RejectDate" + StageNum, Cstr(Now))

	currDoc.FARStatus = "Rejected"

	currDoc.DisplayFARStatus = "Rejected"

	currDoc.AssignedTo = ""

	currDoc.AssignedDate = ""

	

	If currDoc.FARType(0) = "Service Request" Then

		mailDocSubject = "Your Service Request for " + currDoc.FARReqFor(0) + " has been rejected by "+ nam.Common

		mailDocHrefText = "The following Service Request has been rejected ----- Reason: " & currDoc.rejectReason(0) & " ------> "

	Else

		mailDocSubject = "Your FAR for " + currDoc.FARReqFor(0) + " has been rejected by "+ nam.Common

		mailDocHrefText = "The following FAR has been rejected ----- Reason: " & currDoc.rejectReason(0) & " ------> "

	End If

	

	maildocURL = path + "0/" + currDoc.UniversalID

	mailDocFrom = nam.Common

	If stageNum <> "1" Then

		Dim CCtoList As String

		For x = 1 To Cint(stageNum)

			If x = 1 Then

				CCtoList = currDoc.GetItemValue("Route" + Cstr(x))(0)

			Else

				CCtoList = CCtoList + "," + currDoc.GetItemValue("Route" + Cstr(x))(0)

			End If

		Next

		mailDocCopyTo = Split(CCtoList,",")

	End If

	Call MimeMailer(currDoc.Author(0), mailDocCopyTo, mailDocSubject, maildocURL, mailDocHrefText, mailDocFrom)

End If

End Sub

Subject: RE: Submit Is Not Saving The Document

Basically we think it’s a short circuit from the moment we submit till when the WQS agent grabs it… It’s loosing the value we set in javascript when it goes to the agent…

Subject: RE: Submit Is Not Saving The Document

I have only used DOM programming to create stuff on the fly that I do not need to save to the document but have you tried replacing

document.getElementById(‘approverFlag’).value=‘reject0’+num;

with

document.forms[0].approverFlag.value = ‘reject0’ + num;

Failing that I would keep it simple and debug it by adding an alert after you set the field to display its value and then create another agent that you call in the webquerysave that only displays the value of this field.

Subject: RE: Submit Is Not Saving The Document

Chris,

Matt is correct. You are not really storing a value in the approverFlag field with your getElementById() notation.

Ken

Subject: RE: Submit Is Not Saving The Document

I’ve been using that for a while… I actually set it and then alerted on the field value it showed…

Subject: RE: Submit Is Not Saving The Document

After document.getElementById(‘approverFlag’).value=‘reject0’+num;

add

alert(document.getElementById(‘approverFlag’).value);

alert(document.forms[0].approverFlag.value);

If you do not get the same value displayed then the last alert will be the value that is stored when you submit the document.

Also to test that the correct value is being sent to the webquerysave agent print the value of the field to the browser and then exit without running any of your other code. You will then know whether the wrong value is being passed or whether it is the code in the agent that is the problem.

You are also setting rejectReason by the same method. Is this value being set correctly?

Subject: RE: Submit Is Not Saving The Document

I tried the test like below and both came back as whittle…

document.forms[0].approverFlag.value=‘whittle’;

document.getElementById(‘approverFlag’).value = ‘whittle’;

alert(document.forms[0].approverFlag.value);

alert(document.getElementById(‘approverFlag’).value);

Btw thanks for all your help and attention on this…

Subject: RE: Submit Is Not Saving The Document

document.forms[0].approverFlag.value=‘whittle’;document.getElementById(‘approverFlag’).value = ‘whittle’;

alert(document.forms[0].approverFlag.value);

alert(document.getElementById(‘approverFlag’).value);

As you are setting approverFlag using the two different syntaxes then I would expect both to return the same value. What happens if you remove the line

document.forms[0].approverFlag.value=‘whittle’;

Where is your code that submits the document? Is it in a function and if so where do you call it from?

Have you tried printing the value of the approverFlag field in the webquerysave agent and doing nothing else and if so do you get the value you expect?

One thing I have noticed and it surely can’t be this simple is that you don’t have a semi colon at the end of

alert (“You Must Enter A Reson For Rejecting The Far”)

Still I have wasted many an hour tearing my hair out debugging something that has been as simple as a missing semi colon or a typo.

Subject: Submit Is Not Saving The Document

Basically we think it’s a short circuit from the moment we submit till when the WQS agent grabs it… It’s loosing the value we set in javascript when it goes to the agent…