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

x
?
Solved

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

Posted on 2003-11-10
9
Medium Priority
?
275 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 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