Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

changing approval logic from one thread to three

Posted on 2008-11-19
7
Medium Priority
?
230 Views
Last Modified: 2013-12-18
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

0
Comment
Question by:everetjo
  • 4
  • 3
7 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 23000053
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
 

Author Comment

by:everetjo
ID: 23004367
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
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 2000 total points
ID: 23004810
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:everetjo
ID: 23007112
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 23020842
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
 

Author Comment

by:everetjo
ID: 23092058
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
 

Author Closing Comment

by:everetjo
ID: 31518302
Sjef, thanks again for all the valuable insight and suggestions.  
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question