Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Closing doc 1 and opening doc 2

Posted on 2007-03-20
6
Medium Priority
?
206 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
[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
6 Comments
 
LVL 22

Accepted Solution

by:
Bill-Hanson earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 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