Does QuerySave event fire when saying document via Lotusscript?

Hi all

I have a database that when a button is pressed, creates a document within a second database via lotusscript.  The document within the second database has lotusscript in the querysave/postsave events that sends a couple of emails, but these emails are not being sent when the document is created and saved via the button in the first db, only when created manually in the second db.

My question is this:  Do the querysave/postsave events fire when a document is created and saved via lotusscript?

The (stripped down) button code from the first db is like so:
	Dim ws As New notesuiworkspace
	Dim session As New NotesSession
	Dim doc As NotesDocument, maildoc As notesdocument, incident As notesdocument
	Dim uidoc As NotesUIDocument
	Dim db As notesdatabase, CAdb As New notesdatabase("","")
	Dim rtitem As NotesRichTextItem
	
	Set db = session.CurrentDatabase   ' ***** DB 1
	Call CAdb.Open(db.Server,"CorrectiveAction.nsf")   ' ***** DB 2
	Set uidoc = ws.CurrentDocument
	Set doc = uidoc.Document
	
	doc.Status = "Authorised"
	doc.DecisionDate = Today
	Call doc.Save(True, False)
	
	Set incident = New NotesDocument(CAdb)
	incident.date = doc.decisiondate(0)
	incident.username = session.CommonUserName
	incident.category = "IFS Data"
	incident.productIFS = doc.part(0)
	incident.DescriptionIFS = doc.descrip(0)
	incident.etchingIFS = doc.etching(0)
	incident.supplierIFS = doc.supplier(0)
	incident.stockcat = doc.StockCat(0)
	incident.details = doc.reason(0) & " - " & doc.comments(0)
	incident.qtyIFS = doc.qty(0)	
	incident.priority = "Medium"
	incident.problemfound = "Customer Service"
	incident.form = "Incident"
	Call incident.ComputeWithForm(False, False)
	Call incident.save(True, False)
	
	uidoc.close

Open in new window


And the email part of the PostSave event of the form for the newly created document in DB 2 is as follows:

	Dim maildoc As notesdocument
	Dim session As New NotesSession
	Dim doc, profile As notesdocument	
	Dim db As NotesDatabase
	
	Set doc = source.Document
	Set db=session.CurrentDatabase	
	Set profile = db.GetProfileDocument("ProfileDoc")
	
' EMAIL USER TO SAY INCIDENT HAS BEEN RECEIVED IF EMAIL FLAG IS NOT SET	
	If doc.CreatorMailed(0) = "0" Then
		Set maildoc = New NotesDocument(db)
		maildoc.sendto = doc.Username(0)
		maildoc.Subject = "Your Corrective Action Incident Report (" & doc.IncidentNo(0) & ") has been received"
		maildoc.Form = "Memo"
		maildoc.From = "Corrective Action"
		maildoc.Principal = "Corrective Action"
		Set rtitem = New NotesRichTextItem(maildoc, "Body")
		Call rtitem.AppendText("Your Corrective Action Incident Report has been received.")
		Call rtitem.addnewline(2)
		Call rtitem.AppendText("You will be notified of the progress of your incident through the various stages of Corrective Action.")
		Call rtitem.addnewline(2)
		Call rtitem.AppendText("To open the Incident document, please click here ---> ")
		Call rtitem.AppendDocLink(doc, "Link")
		Call maildoc.Send(False)
		doc.CreatorMailed = "1"
		Call doc.Save(True, False)
	End If
	
' EMAIL CORRECT CAR RAISERS TO NOTIFY OF NEW INCIDENT
	If doc.Notify(0) = "0" Then
		If doc.Category(0) = "IFS Data" Then
			Set maildoc = New NotesDocument(db)
			maildoc.sendto = profile.dep6
			maildoc.Subject = "A Corrective Action Incident Report (" & doc.IncidentNo(0) & ") has been received"
			maildoc.Form = "Memo"
			maildoc.From = "Corrective Action"
			maildoc.Principal = "Corrective Action"
			Set rtitem = New NotesRichTextItem(maildoc, "Body")
			Call rtitem.AppendText("A Corrective Action Incident Report has been received in the 'IFS Data' category.")
			Call rtitem.addnewline(2)
			Call rtitem.AppendText("Please action this Incident Report as soon as possible.")
			Call rtitem.addnewline(2)
			Call rtitem.AppendText("To open the Incident document, please click here ---> ")
			Call rtitem.AppendDocLink(doc, "Link")
			Call maildoc.Send(False)
		End If
		doc.Notify = "1"
		Call doc.Save(True, False)
	End If

Open in new window

Bristan_Service_DeskAsked:
Who is Participating?
 
Bill-HansonConnect With a Mentor Commented:
Well, yes and no.

QuerySave is an event for NotesUIDocument, not NotesDocument.

The correct way to handle this is to place your PostSave code in a shared LotusScript library, then reference your shared function in both places: the form's PostSave event and the LotusScript behind the button.
0
 
Sjef BosmanGroupware ConsultantCommented:
If I may, I prefer to explain this differently. The QuerySave and PostSave events are in a form, whereas you create a document directly in the back-end, which happens entirely without a form. Even if you explicitly call ComputeWithForm, the LotusScript events won't be triggered.

So, when you create a document in the back-end, you have to do everything yourself:
- set the Form field
- set $ConflictAction
- do calculations
- etc.

A good solution is, as Bill says, to put functions in a library.
0
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.

All Courses

From novice to tech pro — start learning today.