Solved

Changing computed values in child documents automatically when the parent is changed

Posted on 2003-11-10
9
265 Views
Last Modified: 2013-12-18
Hi experts,
I've got a database in which I have documents, responses, and responses to responses (r2rs).
These response and r2r forms both have a field that is composed when the r or r2r is created from the value of this field, called "node", in the initial document.  
I want to allow users to change the value of  "node" and then the computed values in the children also changed automatically. I have the following code in the main document form:

Sub Postsave(Source As Notesuidocument)
      If Not(Source.IsNewDoc) Then
            Dim doc As NotesDocument
            Dim dc As NotesDocumentCollection
            Set doc = Source.Document
            Set dc = doc.Responses
            Call dc.StampAll("Node" , doc.Node(0))
      End If
End Sub

This works fine for the response documents. The snag is, this doesn't do the trick for the r2rs. Notes help seems to suggest that it does deal with the r2rs. Any ideas why it doesn't for me?
Thanks,
Stuart
0
Comment
Question by:StuartOrd
  • 4
  • 3
  • 2
9 Comments
 
LVL 31

Expert Comment

by:qwaletee
ID: 9718512
doc.responses only returns immediate responses (the docs are very clear on this).  The stampAll method has nothing to do with responses; it takes any document collection, such as doc.responses.  It doesn't know whether the collection came from responses or something else.

There are two basic ways around this: You either have to walk the document response hierarchy (recursively), or walk down a NotesViewNavigator tree created by CreateViewNavFromDescendants.

Either way, stampAll won't do much here.

A third possibility would allow you to use stampAll, but you would have to add some structure to teh adtabase.  You need to mark the r2r docs with the top parent UNID.  Then, create a view that sorts on Ultimate Parent UNID (have this field exist consistently on all documents EXCEPT the top parent).  Then, you can use getAllDocumentsByKey against that view to get a collection of al responses, and use stampAll on it.

You will, of course, have to retrofit all existing r2r documents with the ultimate parent UNID, if you wish to do this.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9718826
Stuart there is nothing wrong in your code it is just that you have to traverse all the response levels to get responses get their values

Here is something that can be implemented easily, I just took your code and modified it to take care of levels of responses

This will be main calling routine

      Dim doc As NotesDocument
      If Not(uidoc.IsNewDoc) Then
            Set doc = uidoc.Document
            Call stampResponses(doc, doc.node(0))  
      End If      

Function stampResponses(note As NotesDocument, node As String)
      Dim doc As NotesDocument
      Dim dc As NotesDocumentCollection
      Set dc = note.Responses
      If dc.Count > 0 Then
            Set doc = col.GetFirstDocument
            While Not doc Is Nothing
                  Call stampResponses(doc, node)  ' Traverse n levels of responses
                  Set doc = col.GetNextDocument(doc)
            Wend
      End If
      Call dc.StampAll("Node" , node)
End Function

~Hemanth
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9719345
Hemanth,

WHy bother with stampAll at that point?  You are traversing every doc in every collection anyway!
0
 

Author Comment

by:StuartOrd
ID: 9721815
Hi Hemanth,
That looks a good way to do it. I've tried it and got the error "Object variable not set" on line  "If Not(uidoc.IsNewDoc) Then"
Stuart
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9722609
Oh I assume u had uidoc set somewhere anyway use source as it is already available

     Dim doc As NotesDocument
     If Not(Source.IsNewDoc) Then
          Set doc = uidoc.Document
          Call stampResponses(doc, doc.node(0))  
     End If    
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 125 total points
ID: 9722626
Sorry one more correction

     Dim doc As NotesDocument
     If Not(Source.IsNewDoc) Then
          Set doc = Source.Document
          Call stampResponses(doc, doc.node(0))  
     End If    

0
 

Author Comment

by:StuartOrd
ID: 9723978
Hi Hemanth,

That's cracked it! I had to make a small change to the Function code -
"doc = col.GetFirstDocument" should read
"doc = dc.GetFirstDocument" etc.

Many thanks

Stuart
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9724378
thanx for correcting
0
 

Author Comment

by:StuartOrd
ID: 9726605
That's OK - at least I'm learning a bit! I only put up final versions so that people will find what worked for me if they search for answers     ;-)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now