Solved

Closing doc 1 and opening doc 2

Posted on 2007-03-20
6
193 Views
Last Modified: 2013-12-18
Hello

The Scenario :
I have a "Request" document which contains a unique "RequestNo".  
As users action the requests, they create "TimeEntry" documents to log their activity and time spent on the request. These time entry documents inherit the RequestNo from the Request document.
Basically, when the main request document is submitted, the user can choose to just submit the request - which is fine, it simply saves and closes.
However, they need an option to submit the request but then automatically be taken to the time entry form to log time for the request. When they do log time, they should be brought back to the main request.
The main request document has an embedded view that displays the time entries for that request.

The Problem :
I have this all working using formula to save the request document and compose the time entry document. However, as the main request document is still open behind it,  when the timeentry document is submitted, the embedded view is not refreshed with the new time entry.

Having tried all sorts of refresh methods to no avail, I have decided that the best course of action is for the button that submits the request and composes the time entry document be in lotusscript, and have it close the main document and compose the time entry, then on submit of the time entry document, compose the main request document again.


Question 1 - What is the code for submitting and closing the request document and composing the time entry document with the Request field parsed

Question 2 - What's the code for submitting the Time entry document, closing it and composing the main request document

 
500 points as it's urgent...

Thanks
0
Comment
Question by:intouchsystems
  • 2
  • 2
6 Comments
 
LVL 22

Accepted Solution

by:
Bill-Hanson earned 500 total points
Comment Utility
First, using your existing method of leaving the Request form open while the TimeEntry form is being edited, have you tried calling NotesUiWorkspace.ViewRefresh() in TimeEntry.QueryClose?  It works most of the time, but will not refresh the correct view sometimes when there are many windows are open.

Questoin 1:  In Request.PostSave:
Dim ws as New NotesUiWorkspace()
dim docRequest as NotesDocument
Dim docTimeEntry as NotesDocument

set docRequest = Source.Document
set docTimeEntry = docRequest.ParentDatabase.CreateDocument()
docTimeEntry.Form = "TimeEntry"
docTimeEntry.RequestNo = docRequest.GetItemValue("RequestNo")(0)
call ws.EditDocument(true, docTimeEntry)
call Source.Close()

Question 2:  In TimeEntry.PostSave:
Dim ws as New NotesUiWorkspace()
dim vwRequests as NotesView
dim docRequest as NotesDocument
Dim docTimeEntry as NotesDocument
dim strKey as String

set docTimeEntry = Source.Document
strKey = docTimeEntry.GetItemValue("RequestNo")(0)
set vwRequests = docTimeEntry.ParentDatabase.GetView("RequestsByRequestNo")
set docRequest = vwRequests.GetDocumentByKey(strKey, true)
call ws.EditDocument(true, docRequest)
call Source.Close()

That ought to do it.
0
 

Author Comment

by:intouchsystems
Comment Utility
Hi Bill

Thanks for your post.
If I put the first bit of code in the 'postsave' event on the request form, this will execute irrelevant of whether the user chooses to create a time entry straight after submission or not - how should this be adapted for the relevant submit button?

(Note - there are two submit buttons on the request form, 1. Submit Request, 2. Submit Request and Log Tim)

Thanks
0
 
LVL 22

Expert Comment

by:Bill-Hanson
Comment Utility
Easy.  Set a temporary field.  You could use a checkbox directly on the form or set a field value in an action button.  For example, if you put this code behind a "New Time Entry" action button:

FIELD tmpComposeTimeEntry = "1";
@If(@Command([FileSave]);  @Command([FileCloseWindow]) ; @Return("") );

Then the PostSave code should be something like this:

Dim ws as New NotesUiWorkspace()
dim docRequest as NotesDocument
Dim docTimeEntry as NotesDocument

set docRequest = Source.Document
if (docRequest.GetItemValue("tmpComposeTimeEntry")(0) = "") then exit sub
set docTimeEntry = docRequest.ParentDatabase.CreateDocument()
docTimeEntry.Form = "TimeEntry"
docTimeEntry.RequestNo = docRequest.GetItemValue("RequestNo")(0)
call ws.EditDocument(true, docTimeEntry)
call Source.Close()
call docRequest.RemoveItem("tmpComposeTimeEntry")
call docRequest.Save(true, false)

In the example above, we set the value of a temp field (tmpComposeTimeEntry) in the action, then PostSave checks the value and removes the field as required.
0
 

Author Comment

by:intouchsystems
Comment Utility
Hi Bill

It almost works!

The Time entry document won't compose unless I remove this line of code :

      Call docRequest.RemoveItem("tmpComposeTimeEntry")

However, obviously if I remove it, then anytime I save changes to the document, a new time entry document is created on submit as the field is still set. Any ideas?
Also, when I do submit the request document, it asks me if I want to save my changes - should there be another save statement in there to prevent this?

Thanks for your help
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now