Solved

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

Posted on 2003-11-10
9
266 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lotes Notes 8.5.3 std can not open calendar 2 99
Lotus notes email code 2 119
Why the url within notes is no action 6 45
Email Forward: Get Around Relay Issue 3 109
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

912 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

21 Experts available now in Live!

Get 1:1 Help Now