Backend Help (y)

I have a approval button in a view and I have no problem using backend methods to set the status to approved. The issue I have is appending a history message to the existing message. I want to be able to get the old history value, write a transaction, and place it at the end of the old history value and I’m not sure how to do that:

Here is my code thus far:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Set db = session.CurrentDatabase

Set collection = db.UnprocessedDocuments

Set doc = collection.GetFirstDocument()



count = 0



While Not(doc Is Nothing)

	

	Set item = doc.GetFirstItem( "Approver" )

	Set status = doc.GetFirstItem( "Status" )

	

	Set nam = session.CreateName( _

	session.UserName)

	

	If item.Contains( nam.common) And status.contains("Pending Approval") Then

		

		doc.Status = "Approved"

		Call doc.Save( False, True )

		count = count +1

		doc.ApprovedBy = nam.common

		doc.approvalDete = Today

		

		

		'Dim oldhistory As String

		'oldhistory =doc.fieldgettext("History")

		

		'Dim newhistory As String

		'newhistory = oldhistory + ";" + nam.common + " has approved the time sheet on " 

		'Call doc.fieldsettext("History", newHistory  + Today)

		

		

	End If

	Set doc = collection.GetNextDocument(doc)

Wend



Msgbox(count) + "  timesheets approved."



Dim ws As New NotesUiWorkspace

Call ws.ViewRefresh

Subject: Backend Help (y)

Hi. First check if your “History” field is a text - multi-values enabled. Try with next code:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Set db = session.CurrentDatabase

Set collection = db.UnprocessedDocuments

Set doc = collection.GetFirstDocument()



count = 0



While Not(doc Is Nothing)

	

	Set item = doc.GetFirstItem( "Approver" )

	Set status = doc.GetFirstItem( "Status" )

	

	Set nam = session.CreateName( _

	session.UserName)

	

	If item.Contains( nam.common) And status.contains("Pending Approval") Then

		

		doc.Status = "Approved"

		

		count = count +1

		doc.ApprovedBy = nam.common

		doc.approvalDete = Today

		

		

		Dim oldhistory As NotesItem

		Set oldhistory = doc.GetFirstItem("History")

		

		Dim newhistory As String

		newhistory = oldhistory + ";" + nam.common + " has approved the time sheet on " 

		oldhistory.AppendToTextList(newHistory + Cstr(Today))			

		Call doc.Save( False, True )

	End If

	Set doc = collection.GetNextDocument(doc)

Wend



Msgbox(count) + " timesheets approved."



Dim ws As New NotesUiWorkspace

Call ws.ViewRefresh

I hope it help you.

Regards

Subject: RE: Backend Help (y)

Sorry, next code is ok:

Dim newhistory As String

		newhistory = nam.common + " has approved the time sheet on " 

		oldhistory.AppendToTextList(newHistory + Cstr(Today))			

		Call doc.Save( False, True )

Subject: RE: Backend Help (y)

Worked like a charm. Thanks!