Solved

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

Posted on 2003-11-10
9
273 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
[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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

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…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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