changing approval logic from one thread to three

I have a document that uses LotusScript logic in the QuerySave event to track approvals.

the form is mailed to an approver via a "send to approver" button, the approver has an approve button, and the approve button sets the status to approved.

If the status = approved, then doc.IsApproved = 1, and record the current user and time.
otherwise, just save the doc.

Now, I need to track three status threads: SpecStatus, TestStatus, PostImpStatus

I've tried to create two more send for approval, two more approve where these buttons set to approve.  I think that my problem is with the doc.IsApproved flag.

Here is the working code and my attempt at the three thread tracking.

I'm new to LotusScript, so I apologize in advance for code that's not elegent.

WORKING CODE
--------------
Sub Querysave(Source As Notesuidocument, Continue As Variant)
	On Error Goto catcherror
	
	Dim doc As notesDocument
	Dim sess As New Notessession
	Dim VarSysStatus As Variant
	Dim vardocsapproved As Variant
	Dim vardocsappdate As Variant
	Dim db As NotesDatabase
	
	Set doc = Source.Document
	Set db = sess.CurrentDatabase
	varSysStatus = doc.SysStatus
	varDocsApproved = doc.DocsApproved
	varDocsAppDate = doc.DocsAppDate
	If Not doc.HasItem("IsApproved") Then
		
		If doc.SysStatus(0) = "APPROVED" Then
			doc.IsApproved = "1"
			doc.DocsApproved = sess.CommonUserName
			doc.DocsAppDate = Now()
		End If
	End If
	Exit Sub
	
catcherror:
   ' Print error description on Status bar:
	Print "ERROR in QuerySave"": "  & Str(Err) _
	& " " & Error$ & " on row " & Cstr(Erl)
	Exit Sub
	
End Sub
END WORKING CODE
--------------
Sub Querysave(Source As Notesuidocument, Continue As Variant)
	On Error Goto catcherror
	
	Dim doc As notesDocument
	Dim sess As New Notessession
	Dim VarSpecStatus As Variant
	Dim VarTestStatus As Variant
	Dim VarPostImpStatus As Variant
	Dim VarSpecsDocsApproved As Variant
	Dim VarTestDocsApproved As Variant
	Dim VarPostImpDocsApproved As Variant
	Dim VarSpecsDocsAppdate As Variant
	Dim VarTestDocsAppdate As Variant
	Dim VarPostImpDocsAppdate As Variant
	Dim db As NotesDatabase
	
	Set doc = Source.Document
	Set db = sess.CurrentDatabase
	varSpecStatus = doc.SpecStatus
	varTestStatus = doc.TestStatus
	varPostImpStatus = doc.PostImpStatus
	varDocsApproved = doc.DocsApproved
	varDocsAppDate = doc.DocsAppDate
	If Not doc.HasItem("SysIsApproved") Then
		
		If doc.SpecStatus(0) = "APPROVED" Then
			doc.SysIsApproved = "1"
			doc.SysDocsApproved = sess.CommonUserName
			doc.SysDocsAppDate = Now()
		End If
	End If
	
	If Not doc.HasItem("TestIsApproved") Then
		
		If doc.TestStatus(0) = "APPROVED" Then
			doc.TestIsApproved = "1"
			doc.TestDocsApproved = sess.CommonUserName
			doc.TestDocsAppDate = Now()
		End If
	End If
	
	If Not doc.HasItem("PostImpIsApproved") Then
		
		If doc.PostImpStatus(0) = "APPROVED" Then
			doc.PostImpIsApproved = "1"
			doc.PostImpDocsApproved = sess.CommonUserName
			doc.PostImpDocsAppDate = Now()
		End If
	End If
	Exit Sub
	
catcherror:
   ' Print error description on Status bar:
	Print "ERROR in QuerySave"": "  & Str(Err) _
	& " " & Error$ & " on row " & Cstr(Erl)
	Exit Sub
	
End Sub

Open in new window

everetjoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantCommented:
Important question: parallel or serial? Meaning: do you always send it to X first, then to Y and finally to Z? Or do X, Y and Z receive a mail simultaneously?

If it's serial, then you have to add a status-field, with values like:
- NEW
- CREATED
- APPROVEDBYX
- APPROVEDBYY
- APPROVEDBYZ
- APPROVED
0
everetjoAuthor Commented:
it's serial.  first specs are approved, then testing, then post imp.  the only problem would be specs changed ( not common) i would have to reset the approved flag for specs and restart
0
Sjef BosmanGroupware ConsultantCommented:
Almost any workflow problem can be solved by defining the right states and a state transition diagram (STD). It describes the states and the events that can occur that make the object go to a different state. A drawing is easy, but a table that lists states and events can also be used.

Example:
Car (the other cells of the table define an action and a next state ( - means no change)
 
		Event
		Car from left	Car from right	Red light	Green light	Car stopped
State
DRIVING		-		Hit Breaks	Hit Breaks	-
		-		STOPPING	STOPPING	-
STOPPING									Wait
										STOPPED
STOPPED								Accelerate
								DRIVING
 
Etc...
 
The empty places can be discussed, so as to fill the entire table. Then you can start to build the application.

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

everetjoAuthor Commented:
it's not a true workflow; when i only had one approval, I sent doclinks and i use hide whens on the buttons depending on whether or not the doc is approved and if you're the approver.

it's attached below, renamed as mdb
EE.ProductWorkflow.11.20.8.mdb
0
Sjef BosmanGroupware ConsultantCommented:
Whether it's a true workflow or not is not very relevant. Using a state transition diagram is usually very handy in these cases, and it involves one field in every document plus all the hide-whens and other logic that depends on it.
0
everetjoAuthor Commented:
this was a mostly a RTFM problem, coupled with some bad organization. after some study, I was able to fix my syntax and get the function working.  Sjef's suggestions regarding the state transition diagram were very helpful and will go in all my future documentation.
0
everetjoAuthor Commented:
Sjef, thanks again for all the valuable insight and suggestions.  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.