×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to Inherit value in previous response document

How to Inherit value in previous response document

How to Inherit value in previous response document

(OP)
I have created a system for medical tracking. Main document will be a personnell particulars info and response document will show the transaction of medical activities untill peryear end. Every person entitled for RM1000 peryear for  medical treatment benefit. Every time they visit the doctor the amount RM1000 (total amount field) will be deducted based on the cost of medical. The deducted amount is called amount balance in amount balance field. How to inherit value from amount balance into the new created document (in total amount field) in response document? Please help me and thank you in advance.

RE: How to Inherit value in previous response document

Let me guess : each new visit is recorded by creating a document from the main document, right ?
In that case, the previous AmountBalance is contained in a response document somewhere under the main doc, response which is not being used for creating the response.
You can develop the code to use a response doc to respond to a main doc. Notes specifically handles that, given that a Response form can be created from a response, but will respond to the main document. Yet, it will inherit from the response doc.
However, I do not think you should rely on the operator to choose the right response document all the time. People are human and humans make mistakes. If the mistake is that they did not choose the right customer record, well, there is no safeguard against that. But you can avoid the mistake of not choosing the right record by not inheriting that value.
Instead, have the response form use the QueryOpen event to look up the last response document and store the value in a temporary variable. The PostOpen event can then use that to fill in the AmountBalance field.
You will need a view to do the lookup, and you will almost certainly need to do the lookup in LScript.
Aside from that, this issue should not be all that difficult to solve.
I'm willing to help if need be.

Pascal.

RE: How to Inherit value in previous response document

(OP)
I am a beginner. Can I have some sample lotus scipts on:
1) how to lookup the last response and store the value in a temporary variable,
2)Lotus Script in PostOpen  to fill in the AmountBalance field.
Thank you very much  

RE: How to Inherit value in previous response document

Before creating code for looking up a document, you need a view that presents documents in a certain way.
It is up to you to determine how the view should present the documents.
You can then write the lookup code, depending on how the view was set up.

Here, we have main documents and response documents. The two are based on two different forms.
A response doc is defined by the fact that the record created always contains a field named $Response. This field contains the UniversalID of the main document that it responds to.
So what you can do is create a view listing all main and response docs, without respecting hierarchy (it is a property of the view). This detail is generally important for purposes of sorting.
The first column of this view should contain a formula like this :

@if(form=<main form name>;@text(@documentuniqueID);$Response)

In the next column, you want the field containing the remaining amount.
Both columns must be sorted. The first can be sorted either ascending or descending. The second column must be sorted descending.

Once you have this view working, searching for the last doc is a trivial exercise in LScript. The code to do it is as follows :

dim session as new notessession
dim uiws as new notesuiworkspace
dim uidoc as notesuidocument
dim db as notesdatabase
dim view as notesview
dim coll as notesdocumentcollection
dim doc as notesdocument
dim dockey as string

set uidoc = uiws.currentdocument
set db = session.currentdatabase
dockey = uidoc.fieldgettext("$Response")
if not (dockey = "") then
set view = db.getview(<view name>)
set coll = view.getalldocumentsbykey(dockey)
if coll.count > 0 then
set doc = coll.getlastdocument
call uidoc.fieldsettext("AmountBalance",doc.AmountBalance(0))
end if
end if


Now, a few remarks.
* First, this code supposes that all response docs are created from the main doc only. If that is not the case, you will have to amend the code a bit to take into account creating from the main doc and creating from a response doc.
* Second, it requires that the field $Response be created on the response form. Make it a hidden field, type text and editable. Put no formulas in the field definitions.
* Third, it supposes that the search code is put in the PostOpen event of the Response form. The reason for that is that the UIdoc is only available after the document has actually been opened. You could design something similar for the QueryOpen event, but you would have to keep the info stored somewhere until the PostOpen was available anyway.

There, that should be enough to get you started.

Good luck !

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close