Solved

Closing doc 1 and opening doc 2

Posted on 2007-03-20
6
195 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
ID: 18755686
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
ID: 18762522
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
ID: 18763340
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
ID: 18767491
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

14 Experts available now in Live!

Get 1:1 Help Now