Solved

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

Posted on 2003-11-10
9
269 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Suggested Solutions

Title # Comments Views Activity
How to access Names.nsf DB from a C# application 14 1,582
Domino Server 2 80
Domino Lotus Notes Client 4 72
Outlook Contact Export as .msg trying to import in Lotus Notes 5 112
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
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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