Should versioning be used or not?

I posted this a few days ago but really didn’t ask the question like this.

My database is a document approval database. The user enters a doc and then the doc goes through approval levels sending emails to each approver.

Once documents go approved, users are “NOT” allowed to make changed/revisions to the document. I need to figure out how to copy the document then clear certain fields so users can make revisions.

@setfield could do that but the fields are in a conrtolled section and change to “read only” once the document goes approved.

The easiet thing would be to tell the users they have to recreate the docs but they will waste time doing it this way.

I’m not sure if versioning should be used here. Actually I’ve never used versioning.

Has anyone done anything like this?

Thanks for any suggestions…

Subject: Should versioning be used or not?

Not sure if this would help you now, but maybe someone who does a search for this type of issue.

What I did was to make a “Suffix” creation from the key generated by the main document. I used the sequebntial number code from the sandbox to generate my main key(IE: SR-00-0001), with SR being the Tag (for Service Request) the two digit being the last two in the year, and the rmaining 4 digits the sequential number. I have code in there to re-generate the sequnce number document to reset the number back to 1 for every new yeat.

After that, I allow the users to select ONE of the documents in a particular view and have them press a button on that view to create a suffix for that key (basically the same way the parent/child as well as response and response to response works).

The business rules setup for the application are that only 26 suffixes can be created for every main SR. So I use a table in my code using the letters in the alphabet. The code in the button is an @CommandToolsRunMacro, and the agent it runs contains the following:

'**********************************************************************

'***** This  is written to create copies of existent SR's for 

'***** allowing users to create New SR's that are the same type 

'***** of change requested from one previously generated.

'*****

'**********************************************************************



Dim ws As New NotesUIWorkspace, uidoc As NotesUIDocument, uidoc1 As NotesUIDocument,doc As NotesDocument

Dim agent As NotesAgent



Dim session				As New NotesSession

Dim db 						As NotesDatabase

Dim colSelectedDoc	As NotesDocumentCollection

Dim colSuffix				As NotesDocumentCollection

Dim uiviewAllSRs		As NotesUIView

Dim viewAllSRs			As NotesView

Set db 						= session.CurrentDatabase

Set uiviewAllSRs		= ws.currentview

Set viewAllSRs			= uiviewAllSRs.view

Dim originalSR			As NotesDocument

Dim defdoc				As NotesDocument

Dim newSR				As New NotesDocument( db )



Dim user 				As String

user = session.CommonUserName

Dim Auser 			As String

Auser = session.UserName



Dim itemSuffix As NotesItem

Dim itemAuthor As NotesItem

Dim itemSave As NotesItem

Dim item As NotesItem

Dim item1 As NotesItem

Dim item2 As NotesItem

Dim item3 As NotesItem

Dim item4 As NotesItem

Dim item5 As NotesItem

Dim item6 As NotesItem

Dim item7 As NotesItem

Dim item8 As NotesItem

Dim item9 As NotesItem

Dim item10 As NotesItem

Dim item11 As NotesItem

Dim item12 As NotesItem

Dim item13 As NotesItem

Dim item14 As NotesItem

Dim item15 As NotesItem

Dim item16 As NotesItem

Dim item17 As NotesItem

Dim item18 As NotesItem

Dim item19 As NotesItem

Dim item20 As NotesItem

Dim item21 As NotesItem

Dim item22 As NotesItem

Dim item23 As NotesItem

Dim item24 As NotesItem

Dim item25 As NotesItem

Dim item26 As NotesItem

Dim item27 As NotesItem

Dim item28 As NotesItem

Dim item29 As NotesItem

Dim item30 As NotesItem

Dim item31 As NotesItem

Dim item32 As NotesItem

Dim item33 As NotesItem

Dim item34 As NotesItem

Dim item35 As NotesItem

Dim item36 As NotesItem

Dim item37 As NotesItem

Dim item38 As NotesItem

Dim item39 As NotesItem

Dim item40 As NotesItem

Dim item41 As NotesItem

Dim item42 As NotesItem

Dim item43 As NotesItem

Dim item44 As NotesItem

Dim item45 As NotesItem

Dim item46 As NotesItem

Dim item47 As NotesItem

Dim item48 As NotesItem

Dim item49 As NotesItem

Dim item50 As NotesItem

Dim item51 As NotesItem

Dim item52 As NotesItem

Dim item53 As NotesItem

Dim item54 As NotesItem

Dim item55 As NotesItem

Dim item56 As NotesItem

Dim item57 As NotesItem

Dim item58 As NotesItem

Dim item59 As NotesItem

Dim item60 As NotesItem

Dim item61 As NotesItem

Dim item62 As NotesItem

Dim item63 As NotesItem

Dim item64 As NotesItem

Dim item65 As NotesItem

Dim item66 As NotesItem

Dim item67 As NotesItem

Dim item68 As NotesItem

Dim item69 As NotesItem



'**************************************************************************

Dim R(26) As String 

Dim view As NotesView

Dim view1 As NotesView	

Dim LogNo As NotesItem

Dim Sufxchg As Variant

Dim dateTime As New NotesDateTime( "" )

Set db = session.CurrentDatabase

Dim counter As Integer

Dim Found As String

Dim vc As NotesViewEntryCollection

Dim entry As NotesViewEntry

Dim KeyValue As Variant

Dim SufxValue As String



'set up the array for determining the current and the next value

r(0) = "A" ' Default Value

r(1) = "B"  ' Options

r(2) = "C" 

r(3) = "D" 

r(4) = "E" 

r(5) = "F" 

r(6) = "G" 

r(7) = "H" 

r(8) = "I" 

r(9) = "J" 

r(10) = "K"

r(11) = "L" 

r(12) = "M" 

r(13) = "N" 

r(14) = "O" 

r(15) = "P" 

r(16) = "Q" 

r(17) = "R" 

r(18) = "S" 

r(19) = "T" 

r(20) = "U"

r(21) = "V" 

r(22) = "W" 

r(23) = "X" 

r(24) = "Y" 

r(25) = "Z" 



Set colSelectedDoc	= db.UnprocessedDocuments



If colSelectedDoc.Count <> 1 Then

	Messagebox("Please select a single Service Request to create a Suffix document for.....Exiting Agent....")

	Exit Sub

End If 



Set originalSR = colSelectedDoc.getfirstdocument

'Set colRevisions = viewAllMDTs.getalldocumentsbykey( originalMDT.MDTNo(0) )



'...set value of newMDT...

'Set newMDT = New NotesDocument( db )

'Call originalMDT.CopyAllItems( newMDT, True )

'newMDT.RevisionNumber = colRevisions.count + 1

'newMDT.RevisionLevel = "Revision " + Cstr( colRevisions.count )

'newMDT.InfoFrom = originalMDT.RevisionLevel(0)

'Call newMDT.Save( True, True )



Call ws.ComposeDocument( "", "", "Service Request Submission" )



Set uidoc = ws.CurrentDocument

Set newSR=uidoc.document

'Get Suffix for the new SR

'set todays date for suffix creation

dateTime.LSLocalTime = Now

f= dateTime.DateOnly



'...set value of newSR...

'Set newSR = New NotesDocument( db )

'Call originalSR.CopyAllItems( newSR, True )



Set view = db.GetView("(Find SR Suffixes)")

KeyValue= originalSR.SRNo

Set vc = view.GetAllEntriesByKey(KeyValue,True)

If vc.count > 0 Then

	Set entry = vc.GetLastEntry()

	Set doc = entry.Document

	If doc.Suffix(0) = "Z" Then

		Messagebox("There are no more suffix documents that can be created for this Service Request.....Exiting Agent....")

		Exit Sub

	End If

	counter = 0

	Found="N"

	Do While counter < 27 And Found = "N"

		If doc.Suffix(0) = r(counter) Then

			counter = counter + 1

	'next statement is to force users to press Submit

	'Call newSR.ReplaceItemValue("AllowSave","0")

			Set itemSave=newSR.ReplaceItemValue("AllowSave","0")

			

	'next statements are for copying the necessary values before the Submit is done

			Set itemSuffix=newSR.ReplaceItemValue("Suffix",r(counter))

			Set itemAuthor=newSR.ReplaceItemValue("Author",Auser)

			Set item=newSR.ReplaceItemValue("SRNo",originalSR.SRNo(0))

			Set item1=newSR.ReplaceItemValue("SRStatus","New")

			Set item2=newSR.ReplaceItemValue("Date",f)

			Set item3=newSR.ReplaceItemValue("SRReqDate",f)

	'Requestor Area

			Set item4=newSR.ReplaceItemValue("ContactPerson",originalSR.ContactPerson(0))

			Set item5=newSR.ReplaceItemValue("ReqNameOrg",originalSR.ReqNameOrg(0))

			Set item6=newSR.ReplaceItemValue("OtherNameOrg",originalSR.OtherNameOrg(0))

			Set item7=newSR.ReplaceItemValue("RequestTitle",originalSR.RequestTitle(0))

			Set item8=newSR.ReplaceItemValue("SRCnclDate","")

			Set item9=newSR.ReplaceItemValue("SRAppDate","")

			Set item10=newSR.ReplaceItemValue("SRIPDate","")

			Set item11=newSR.ReplaceItemValue("SRComDate","")

			Set item12=newSR.ReplaceItemValue("SRCloseDate","")

			Set item13=newSR.ReplaceItemValue("ChangeDescription",originalSR.ChangeDescription(0))

			Set item14=newSR.ReplaceItemValue("Category",originalSR.Category(0))

			Set item15=newSR.ReplaceItemValue("RequestorCompleteDate",originalSR.RequestorCompleteDate(0))

			Set item16=newSR.ReplaceItemValue("RequestorPriority",originalSR.RequestorPriority(0))

			Set item17=newSR.ReplaceItemValue( "ReproduceSteps", originalSR.ReproduceSteps(0))

	'Cannot do rich text field Screen Shots

			Set item18=newSR.ReplaceItemValue( "BusinessJustification", originalSR.BusinessJustification(0) ) 

	'Cannot do rich text field Business Justification Documentation

			Set item19=newSR.ReplaceItemValue("AdditionalInformation",originalSR.AdditionalInformation(0))

			

	'Status Area (status date not necessary)

			Set item20=newSR.ReplaceItemValue("StatusComments",originalSR.StatusComments(0))

			

	'Process Owners Area

			Set item21=newSR.ReplaceItemValue("DCAAssignedPriority",originalSR.DCAAssignedPriority(0))

			Set item22=newSR.ReplaceItemValue("DCAPriorityNum",originalSR.DCAPriorityNum(0))

			Set item23=newSR.ReplaceItemValue("EnhancementType",originalSR.EnhancementType(0))

			Set item24=newSR.ReplaceItemValue("WhoInvolved",originalSR.WhoInvolved(0))

			Set item25=newSR.ReplaceItemValue("LatitudeAssignedTo",originalSR.LatitudeAssignedTo(0))

			Set item26=newSR.ReplaceItemValue("OtherVendorAssignedTo",originalSR.OtherVendorAssignedTo(0))

			

			Set item69= newSR.GetFirstItem( "RevHistory" )

			Call item69.AppendToTextList( "Service Request Suffix created on "+ f + " by " + user +".")

			

			'Set item3= newSR.GetFirstItem( "RevHistory" )

			'Call item3.AppendToTextList( "Service Request Suffix created on "+ f + " by " + user +".")

			'Call newSR.save(False,True)

			SuffixValue = ""

			Found = "Y"	

		Else

			counter = counter + 1

		End If

	Loop

	

	If Found = "N" Then 'no match was found or limit has been reached

		Messagebox ("There was no match found in the view, or the limit has been reached")		

		continue=False

		Exit Sub

	End If	

Else

'1st Sufxision level document should be set to A

	'next statement is to force users to press Submit

	'Call newSR.ReplaceItemValue("AllowSave","0")

	Set itemSave=newSR.ReplaceItemValue("AllowSave","0")

	

	'next statements are for copying the necessary values before the Submit is done

	Set itemSuffix=newSR.ReplaceItemValue("Suffix","A")

	Set itemAuthor=newSR.ReplaceItemValue("Author",Auser)

	Set item=newSR.ReplaceItemValue("SRNo",originalSR.SRNo(0))

	Set item1=newSR.ReplaceItemValue("SRStatus","New")

	Set item2=newSR.ReplaceItemValue("Date",f)

	Set item3=newSR.ReplaceItemValue("SRReqDate",f)

	'Requestor Area

	Set item4=newSR.ReplaceItemValue("ContactPerson",originalSR.ContactPerson(0))

	Set item5=newSR.ReplaceItemValue("ReqNameOrg",originalSR.ReqNameOrg(0))

	Set item6=newSR.ReplaceItemValue("OtherNameOrg",originalSR.OtherNameOrg(0))

	Set item7=newSR.ReplaceItemValue("RequestTitle",originalSR.RequestTitle(0))

	Set item8=newSR.ReplaceItemValue("SRCnclDate","")

	Set item9=newSR.ReplaceItemValue("SRAppDate","")

	Set item10=newSR.ReplaceItemValue("SRIPDate","")

	Set item11=newSR.ReplaceItemValue("SRComDate","")

	Set item12=newSR.ReplaceItemValue("SRCloseDate","")

	Set item13=newSR.ReplaceItemValue("ChangeDescription",originalSR.ChangeDescription(0))

	Set item14=newSR.ReplaceItemValue("Category",originalSR.Category(0))

	Set item15=newSR.ReplaceItemValue("RequestorCompleteDate",originalSR.RequestorCompleteDate(0))

	Set item16=newSR.ReplaceItemValue("RequestorPriority",originalSR.RequestorPriority(0))

	Set item17=newSR.ReplaceItemValue( "ReproduceSteps", originalSR.ReproduceSteps(0))

	'Cannot do rich text field Screen Shots

	Set item18=newSR.ReplaceItemValue( "BusinessJustification", originalSR.BusinessJustification(0) ) 

	'Cannot do rich text field Business Justification Documentation

	Set item19=newSR.ReplaceItemValue("AdditionalInformation",originalSR.AdditionalInformation(0))

	

	'Status Area (status date not necessary)

	Set item20=newSR.ReplaceItemValue("StatusComments",originalSR.StatusComments(0))

	

	'Process Owners Area

	Set item21=newSR.ReplaceItemValue("DCAAssignedPriority",originalSR.DCAAssignedPriority(0))

	Set item22=newSR.ReplaceItemValue("DCAPriorityNum",originalSR.DCAPriorityNum(0))

	Set item23=newSR.ReplaceItemValue("EnhancementType",originalSR.EnhancementType(0))

	Set item24=newSR.ReplaceItemValue("WhoInvolved",originalSR.WhoInvolved(0))

	Set item25=newSR.ReplaceItemValue("LatitudeAssignedTo",originalSR.LatitudeAssignedTo(0))

	Set item26=newSR.ReplaceItemValue("OtherVendorAssignedTo",originalSR.OtherVendorAssignedTo(0))

	

	Set item69= newSR.GetFirstItem( "RevHistory" )

	Call item69.AppendToTextList( "Service Request Suffix created on "+ f + " by " + user +".")

	'Set item69=newSR.ReplaceItemValue("RevHistory","Service Request Suffix created on "+ f + " by " + user +".")

	'Call newSR.save(False,True)

End If	



Call uidoc.Refresh

Opening the newly created document in the UI, and forcing them to submit it to the appropriate approvers for that document to go thru its normal life cycle, even though the main document can be closed. It blanks out certain key fields (required) so that users would need to fill them back in before they submit it, and clears out all of the workflow and approval fields below the initial approval area so that it will have to follow the approval process from the begginning.

Seems like a ton of work, but worked out for the users and they like the way.

Hope this helps you or someone…

Mick

Subject: Should versioning be used or not?

Versioning can be very useful, but I don’t think it will do what you need it to, because it can’t be conditional based on your approval status - versioning is either on or off. As far as I know that design property can’t be set programmatically. For example, Disable Printing/Forwarding/Copying can be set programmatically by creating a $KeepPrivate field and setting it to 1 when a certain status is set. I don’t think you can do this with versioning, as the only indication of versioning field-wise is a $VerRef field, which contains the UNID of the original document. There’s no way to set which type of versioning to do.

That said, if you can trust your users, you can set versioning up to be manual (as in it creates a new version only when the user chooses File/Save as New Version. )

Otherwise, I’d go with creating response documents that allow them to make changes. If they open the main document and it’s already past the approval status, you can use QueryModeChange code to prevent it being put into edit mode. Then use some easy LotusScript code to create a new copy of the document, make it a response of the original, clear out the fields that you want to be blank, and open the document in the UI for editing.

Subject: Should versioning be used or not?

This sounds like something Domino.Doc or Workflow would do for you easily.