intouchsystems
asked on
Closing doc 1 and opening doc 2
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(" tmpCompose TimeEntry" )(0) = "") then exit sub
set docTimeEntry = docRequest.ParentDatabase. CreateDocu ment()
docTimeEntry.Form = "TimeEntry"
docTimeEntry.RequestNo = docRequest.GetItemValue("R equestNo") (0)
call ws.EditDocument(true, docTimeEntry)
call Source.Close()
call docRequest.RemoveItem("tmp ComposeTim eEntry")
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.
FIELD tmpComposeTimeEntry = "1";
@If(@Command([FileSave]); @Command([FileCloseWindow]
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("
set docTimeEntry = docRequest.ParentDatabase.
docTimeEntry.Form = "TimeEntry"
docTimeEntry.RequestNo = docRequest.GetItemValue("R
call ws.EditDocument(true, docTimeEntry)
call Source.Close()
call docRequest.RemoveItem("tmp
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.
ASKER
Hi Bill
It almost works!
The Time entry document won't compose unless I remove this line of code :
Call docRequest.RemoveItem("tmp ComposeTim eEntry")
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
It almost works!
The Time entry document won't compose unless I remove this line of code :
Call docRequest.RemoveItem("tmp
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
ASKER
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