Updating documents with computed fields

I have a database with documents with some computed fields that I might need to subsequently alter.

For example I have a form called A with text fields called AF1 and AF2. I create a document from it and enter text into these fields. I have a second form B with computed when composed (CWC) fields that are also called AF1 and AF2. These CWC fields have values "AF1" and "AF2" respectively.

I might have many documents in the database created with form B that have all imported data from the single document created using form A. All the B type documents therefore have got their data in fields AF1 and AF2 from the A type document, plus other unique data the user has entered into other fields in form B.

However if there is subsequently a need to change the text in field AF1 or AF2 in the first document, the corresponding CWC field(s) in all the other documents remain unchanged. I tried making them into computed rather than CWC fields, but they still remain unaltered after the data in the document from form A has been changed.

How can I make Notes update these documents so that their CFC fields then contain the updated text in the first document?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantCommented:
There are two ways:
1) the direct way: in the PostSave of form A, you add the necessary functionality to a) look up the related B-documents, and b) update them according to the new value(s) in A
2) the delayed way: use an agent to update the related B-documents, either triggered on when documents are modified or scheduled once per night)  

The relation can be that B-documents share some value with the A-document (use getAllDocumentsByKey), or you set up a hierarchical relation so that all B-documents are responses to an A-document (use docA.Responses).

Both methods have their pros and cons. When using PostSave to update many related documents, you take the risk of save conflicts, whereas the agent may be late. It depends on the type of use of the database.
Also, the Computed When Composed field only updates once (when composed) and the Computed field calculate every time that field gets refreshed.  
Sjef BosmanGroupware ConsultantCommented:
That statement is too vague, please describe the circumstances... ;-)
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

StuartOrdAuthor Commented:
Hi sjef,
Yes, it's that relationship that is giving me difficulty. The nature of the database is such that I needed four levels, so document + response + response to response wasn't enough. Hence document B responds to document A in a logical sense, but not in a hierarchical one, then document B has responses and response to responses to give the four "levels".
Could I create a new field C, hidden from the user, that has a value set automatically in documents from form A and copy the same value into the documents from form B, then write an agent that copies the modified fields AF1 and AF2 etc from the values in the form A document to the corresponding fields in form B documents identified by this hidden value even though the latter are CWC fields?
Sjef BosmanGroupware ConsultantCommented:
So A and B do not have a document-response relationship? How do you intend to find your B-documents then? Ah, the C-field, I C... I suppose there is already some field that references the other database, otherwise you wouldn't have bothered to update anything whatsoever. The question is: what can act as key into the B-view immediately in the PostSave, and what when correcting the B-docs in a much later stage. If I understand you right, your C-field might be what you need. You could use @Unique to create a unique value as key in the A documents, and use that key in the related B-docs.

PS I have a database with 5 doc+response levels, all running smooooothly... ;-)
StuartOrdAuthor Commented:
Yes, but I guess you're on Notes R10 or whatever is the latest which enables that? I'm still on R6.5 as I'm using it on my laptop stand-alone without a Domino server, the security is manageable at my level and my budget for this is way less than they want for the current version!
Sjef BosmanGroupware ConsultantCommented:
Everything I mentioned is there in Formula language since Pocahontas, who didn't like Apache (for obvious reasons). When exactly @Unique was introduced I don't know. Anyway, R6.5 supports it, sorry to spoil your excuse. ;-)
StuartOrdAuthor Commented:
Busy, busy, sorry I've been diverted as usual. OK, I don't need 5 levels.....

Posing questions sometimes clears my thoughts, and I realise now that I don't need 4 levels any more.

If I drop to 3, I could have simply document / response / response to response. So if I did that, would the computed fields in the response and response to response documents get updated when I alter the parent document if I made the fields in the response and r2r forms computed rather than computed when composed? I gave it a try and it didn't seem to change in the test response document. I've only used computed when composed in the past - what is needed to get computed fields to work differently to CWC fields? Or am I barking up the wrong tree? (Or indeed just barking!)
Sjef BosmanGroupware ConsultantCommented:
There are no 3 levels in Notes, only 2: a document is either a parent or a response; the only difference is that a parent has no parent. The 3 level-stuff is only visible/usable in a form: if you define a form as a parent form, the document (when saved from the Notes client's UI) will be saved without a reference to a parent document; if you set it as response-to-response, the document will contain a reference to the document that was the current at the moment of the response's creation; and when you set it as response-only... the document will contain a reference to the highest document in the chain from the current document towards the highest parent, meaning that it is created as response of the ancestor of the whole dynasty.

Hence, don't expect miracles from Notes, because it doesn't do any magic. So, the answer is: No, you have to duplicated shared fields down from the parent to all children.

Computed when composed has a similar misconception: it only exists in the Notes client UI, where it informs the client that a field won't change. Using an agent and back-end classes, you can update any field (NotesItem) in a document, even create or remove fields. That is, if you really have to.

Now for a solution: http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256C75007CFB1A

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
StuartOrdAuthor Commented:
OK thanks, it seems I was barking up the wrong tree due to labouring under that misunderstanding. I'm semi-retiring from work soon, so will have time to learn more about these things then. You (experts) helped me with a StampResponse function some years ago which I'd forgotten about - I need to dig it out again.
Happy Christmas!
Sjef BosmanGroupware ConsultantCommented:
Thanks, also for the Happy Christmas, which I gladly return to you: Merry Christmas, Happy New Year!

If you have some spare time in the future, maybe you can find the time to become an expert yourself. You have valuable knowledge, better put it to use ;-)

By the way, it's called StampAll, and you'd have to use it recursively as well, just like the functions mentioned in the link above. Ah, no, I stand corrected: unless you can get one big collection of all children and grand*children, so you can stamp 'em all in one go. Since you have a stand-alone system, I expect no problems.
By another way: as of R8.5 there also is StampAllMulti, where you can stamp a whole collection of documents with multiple fields at the same time. Powerful!!
StuartOrdAuthor Commented:
Well, maybe, but I'm no expert, just a user. Having started computing no less than 52 years ago when my father became one of the first programmers here for British Steel (they shared a computer with anothe company to do payrolls and later stocktaking and the computer, leased from IBM, occupied a building!) I've used them a lot but not for their own sake - only for what thy can do for me. Today the rate of progress is so fast I can't see me ever becoming an expert (except in historical aspects, perhaps!)
Here's to a better 2012 than many are predicting....if we could control the banks' computers!!
Sjef BosmanGroupware ConsultantCommented:
The EE expert's essential elements in my eyes:
- I know how to analyse a question
- for I'm an expert
- yet there are experts more expert than I
- I'm always willing to learn
- I know I'm fallible
- I'm always willing to help my fellow man
- no obligations (it's not work)
- 90% of help is advice or assistance

I gather that you could qualify easily if you want. Be glad that it doesn't have to be right all the time, mistakes are allowed, kind words are usually appreciated, and you can always bring in another expert. Even the occasional historical note in a discussion can help someone to look at the problem from a different perspective. Don't be too modest!

Let's stay optimistic, and make 2012 an "interesting" year! Cheers!
Steve KnightIT ConsultancyCommented:
British Steel eh.... worked for them too, indirectly -- for a guy called Jim Scharff doing some website work 10 or more years ago then supported all the Corus sites network systems for a year or so ...  good luck with your Notes trials, it's a powerful beast but needs to be done the Notes way!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.