Link to home
Start Free TrialLog in
Avatar of jforget1
jforget1

asked on

Edit History Not Updating

I have an edit history subform that I have embedded in a number of docs that normally works great. For some reason on this one approve button the status does not always update in the edit history properly. I have the doc.Save at the end of the code which should do it, but it does not seem to. Is there something I am missing. The doc is in Edit Mode by default.
Code for Status field in the Edit History 
@If(@IsDocBeingSaved; @If(Status_History = ""; Status; Status_History:Status); @IsNewDoc; ""; Status_History)
 
Here is the code for the Approve button, 
 
Sub Initialize
	Dim session As New NotesSession 
	Dim db As NotesDatabase
	Dim uidoc As NotesUIDocument
	Dim doc As NotesDocument
	Dim emaildoc As NotesDocument
	Dim Item As NotesItem
	Dim twoliner As String
	Dim rtitem As NotesRichTextItem
	Dim sNamesArr(1)As String
	Dim sNamesArrB(1)As String
	Dim installDate As NotesDateTime
	Dim installTimeItem As NotesItem		
	Set db = session.CurrentDatabase
	Set col = db.UnprocessedDocuments
	Set doc = col.GetFirstDocument
	On Error Resume Next
	While Not doc Is Nothing
		If doc.approved_flag(0)<>"done"  And doc.invite_type(0) = "Management Team" Then
			Set emaildoc = db.CreateDocument
			
			emaildoc.form = "nef_bb_approved" 'Form name of Letter
			emaildoc.SendTo = doc.EE_Name(0)
			emaildoc.CopyTo = "Field Technology"
			emaildoc.BlindCopyTo = doc.final_approver
			emaildoc.Principal = "Field Technology"
			emaildoc.approval_code = doc.approval_code
			emaildoc.Subject ="ADG BlackBerry offer approved for " +  doc.name_adjusted(0) + "!" 
			emaildoc.EE_Name = doc.EE_Name
			emaildoc.ReturnReceipt="1"
			Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")
			Call rtitem.AppendDocLink(doc, "") 
			Call emaildoc.Send(True)
			Set emaildoc2 = db.CreateDocument
			
			emaildoc2.form = "nef_bb_approved_to_mgt" 'Form name of Letter
			emaildoc2.SendTo = doc.md(0)
			emaildoc2.CopyTo = doc.om(0)
			emaildoc2.BlindCopyTo = "Field Technology"
			emaildoc2.Principal = "Field Technology"
			emaildoc2.Subject ="ADG BlackBerry offer approved for " +  doc.name_adjusted(0) + "!" 
			emaildoc2.EE_Name = doc.EE_Name
			Call emaildoc2.Send(True)
		End If
		
		If doc.approved_flag(0)<>"done"  And doc.invite_type(0) <> "Management Team" Then
			Set emaildoc = db.CreateDocument
			
			emaildoc.form = "nef_bb_approved" 'Form name of Letter
			emaildoc.SendTo = doc.EE_Name(0)
			emaildoc.CopyTo = "Field Technology"
		'	emaildoc.BlindCopyTo = doc.final_approver
			emaildoc.Principal = "Field Technology"
			emaildoc.approval_code = doc.approval_code
			emaildoc.Subject ="ADG BlackBerry offer approved for " +  doc.name_adjusted(0) + "!" 
			emaildoc.EE_Name = doc.EE_Name
			emaildoc.ReturnReceipt="1"
			Set rtitem = New NotesRichTextItem(emaildoc, "Doclink")
			Call rtitem.AppendDocLink(doc, "") 
			Call emaildoc.Send(True)
		End If
		
		doc.approved_flag = "done"    'field name for flag
		doc.status = "Approved" 
		Call doc.Save(True,True)
		Set doc = col.GetNextDocument(doc)
	Wend
End Sub

Open in new window

Avatar of SysExpert
SysExpert
Flag of Israel image

1) Check the parameters of the Doc.save to make sure that you need  true, true.

2) When does it NOT work ?

3) Try to find a common reason for the issue that will point ot a solution.

I hope this helps !
Avatar of jforget1
jforget1

ASKER

Based on the help, I do not think the True,True is an issue, although I could be wrong. As far as commonality it only seems to happen on this one button, the other button for the various steps do not seem to have the issue, those edits are getting the "stamp" in the edit history. One thing that may have caused some issue, is it seems to have started when I added the second If Then section, but having the Save command outside of the Ifs, I would think that would not be an issue, but it seems to be when this started.
Still struggling with this one, anyone have any other suggestions here.
Is that field Computed?
Check this sample code which I used long back:
@Left(@If(@IsDocBeingSaved; @If(EhStatus = "";status;status : @If(@Elements(EhStatus) > 4; @Subset(EhStatus; 4); EhStatus)); @IsNewDoc; EhStatus; EhStatus); 30)

You code looks OK to me.
@If(@IsDocBeingSaved; @If(Status_History = ""; Status; Status_History:Status); @IsNewDoc; ""; Status_History)
It is a computed field, I am thinking it is something with the sequence of the save in the button code. It only seems to happen with this button.
In the button code, it seems you are triggering the code to a backend document.
I think the code itself is wrong. You are not running the code from a view. You are running the code from a open document....right?

Make the save as False,false and try
If you are running from the view level, is it not updating the status field with Approve? is the field name correct?
THe button is triggered from inside the record itself, not from a view.
Is the document collection code needed if this is triggered inside the record?
ASKER CERTIFIED SOLUTION
Avatar of madheeswar
madheeswar
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Appreciate the help