[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Does QuerySave event fire when saying document via Lotusscript?

Posted on 2011-05-05
2
Medium Priority
?
2,385 Views
Last Modified: 2013-12-18
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

0
Comment
Question by:Bristan_Service_Desk
2 Comments
 
LVL 22

Accepted Solution

by:
Bill-Hanson earned 2000 total points
ID: 35699758
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
 
LVL 46

Expert Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

830 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