Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Postopen code leaves document open twice

Posted on 2003-11-10
9
Medium Priority
?
470 Views
Last Modified: 2013-12-18
This is a weird one for you.

I have a "report" form that collects and formats information from other documents in the database, dumping the results nicely into a rich-text field. The data collection is handled in the Postopen event, if the document is new.

Because the resulting field is rich-text, it does not show updates until the document is closed and reopened. So I have this code at the very end of all the rest of the stuff in the Postopen:

==== BEGIN PASTE ====
      Call Source.Document.Save(True, False)
      Source.Document.SaveOptions = "0"
      Call Source.close
      Call ws.ViewRefresh
      Set uidoc = ws.EditDocument(False, doc)
===== END PASTE =====

Note that doc, in this case, is a NotesDocument that is declared in the form's (Declarations) section (not the Globals (Declarations) section, and its value is set to Source.Document. Likewise, ws is the NotesUIWorkspace that is declared in the (Declarations) section and set as a New NotesUIWorkspace.

This is all fine -- half the time. I have two major classifications of reports that can be generated, based on the user's responses to some ws.Prompts in the PostOpen. For one classification of reports, I have no problems. For the other, when the process is complete the new report is on the screen, but there are two "task buttons" in the bar, indicating that the document is open twice. The first task button contains the calculated name of the re-opened report document, and the second contains the calculated name of a new report document. If you click on the two task buttons, you can go back and forth between the two documents: the one that shows the complete report, and the one that shows the document as it appeared before it was saved.

The two classifications of reports collect information from the same pool of documents, though they collect different information. The report format that exhibits this quirk uses an array of objects of a class declared in the form's (Declarations) section. The array is processed in a subroutine, where it declared dynamically. As the subroutine closes, it runs this code:

==== BEGIN PASTE ====
      For intCount = 1 To Ubound(detailLines)
            Set detailLines(intCount) = Nothing
      Next
      
      Redim detailLines(0 To 0)
      Set detailLines(0) = Nothing
      Set varDetailLines = Nothing
===== END PASTE =====

Obviously, detailLines() is the dynamic array of objects of my class. varDetailLines is another instance of the class.

The report format that doesn't exhibit this quirk does not use any variable type other than the standard Notes classes. I don't know that the class thing is causing my problems, but it is the chief significant difference between the processing of the two formats of report.

Does anyone have any idea how I can get that second "empty" document to not appear? It's all that much more baffling, given that the empty one appears after the "full" document in the Task Button bar. Even more so, when the report generation is complete, the "full" document is showing, though the "empty" task button appears to be selected.

Thanks for any help you can provide. I always like to come in with a good challenge for you!

-- b.r.t.
0
Comment
Question by:BarryTice
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
9 Comments
 
LVL 31

Expert Comment

by:qwaletee
ID: 9718732
Is it a single form that does blth classes of report, or different forms?
0
 
LVL 7

Author Comment

by:BarryTice
ID: 9718764
Same form, qwaletee. Whichever report is generated is dumped into a calculated rich-text field (called "Body", with a formula of Body). That way, when the report is viewed after creation, it's just showing the collected data.
-- b.r.t.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9718882
Here is my suggestion

Create an agent which will collect all the data thru prompts and then Create empty report document with all necessary parameters collected into fields and save it and open the document. Then during QueryOpen using this script get backend handle of the document and then begin processing (you can also do this in agent and after dumping data open the document that is more easy)

Dim session as New NotesSession
Dim db as NotesDatabase
Dim doc as NotesDocument
set db = session.CurrentDatabase
set doc = db.GetDocumentByUNID( Source.Document.UniversalID )
' Here do reporting on the doc -- this will effectively open the report with complete data


~Hemanth
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 31

Expert Comment

by:qwaletee
ID: 9719343
Oh, c'mon, let's try fixing Varry's problem before completely reworking the code.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 9720977
I think Hemanth does have a point here. If doc is set to Source.document, then doc should be Nothing after calling the Close method on Source. It could be that the Close is skipped, for whatever reason, since the form is in the PostOpen and therefore intrinsically open.

Possible solution: get an independent doc and use that one to open the form on the screen. Like the statement
   Set doc = db.GetDocumentByUNID( Source.Document.UniversalID )
0
 
LVL 7

Author Comment

by:BarryTice
ID: 9722214
OK, so I've changed the closing code to this:
==== BEGIN PASTE ====
      strID = doc.UniversalID
      Call Source.Document.Save(True, False)
      Source.Document.SaveOptions = "0"
      Call Source.close
      Call ws.ViewRefresh
      Set doc = db.GetDocumentByUNID(strID)
      Set uidoc = ws.EditDocument(False, doc)
===== END PASTE =====
with strID declared in the Postopen as a string.

No change. I'm still getting two open documents at the end.

In the absence of figuring out what's going on here, I expect I'll end up moving this to an agent. But I'd rather figure out what's going on.

-- b.r.t.
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 1000 total points
ID: 9730509
Weird. But reopening documents for the sake of computed rich text fields has always been an tricky thing. I think it must be a timing issue. You could try to move your code to the QueryClose event, like this:

in Declarations:
Dim process_flag As Integer

in PostOpen:
If "proccessing is required" Then
   process_flag= True
   Call Source.Close
End If

in QueryClose:
If process_flag Then
   ' do_your_thing
End If

If you are going to rework your code, since I wonder why you want to open and reopen the document, you could just use a view button running on unprocessed documents.

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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