This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Dec 18, 2013, 2:25 PM
50 Posts
topic has been resolvedResolved

Response documents vs related documents in XPages

  • Category: Other
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags: xpages,response documents
  • Replies: 3

What is the "best practice" for designing an application with related documents in XPages (apart from a discussion database)? Is it best to use "documents" and "responses" or is it best to use all "documents" and relate them with, say, the Unique ID of the primary document? Are there benefits to one method or the other?

The immediate background for my question is that I am redesigning a legacy notes application to a browser based XPages application. Currently, it uses a single, large form with several instances of Tablewalker on the form in some instances and in other instances just has a bunch of fields for repetitive information. I am considering breaking out several of those "tables" and "globs of fields" to response or secondary documents and displaying them on the XPage using multiple data sources. (eg. Main or primary doc is a personnel bio form. Instead of multiple fields for spouse, children, parents, etc, I will use a response or secondary doc to get name, age, birthdate, etc and display on the xpage in a repeat.)

Thanks for your responses.

 

Dec 18, 2013, 10:34 PM
453 Posts
I used to use the UNID to relate documents but...

I don't do that any more. I now use @Unique. There are several reasons why I have switched. There is no doubt that getting a document by UNID is quicker than opening a view then getDocumentbyKey but I really don't think the price is particularly high.

Reasons Not to use the UNID:

1. If you ever have a save/rep conflict you may destroy the relationship depending on how you resolve the conflict. But then I know you never get any save/rep conflicts :-)

2. When working with a new document and you get the UNID it will be different after the document has been saved. Where I ran into this is a situation where I created a related document from while a document was still new and cost me a lot of time trying to fix it.

Now I just have a field on the form I called it LinkKey (customcontrol) that defaults to @Unique() and go from there. In one case I needed to create 'response to response' documents in the third level down I store both the the Key back to the top level Parent (ie grandParent) as well as the key to the Parent. So I can go back and forth from the child to the parent to the grandparent or from the child directly to the grandParent. I control all the lookup by some very simple views that contain only the LinkKey sorted. I have not tried this in very large DBs, but it works really well in repeat controls where I getAllDocumentsByKey(LinkKey) and feed that into the repeat control. The beauty of this is that you can spread the cost of the lookup over time so that each lookup might be slightly longer that a get by UNID but it is probably never noticeable to the end user.

I have been using this method in native Notes applications (with single category views) as well as in XPages  and repeat controls. Love the repeat control because you have so much more control.

Bill

Dec 20, 2013, 1:19 PM
586 Posts
My thoughts

Rod,

I NEVER EVER use response documents in XPages.  I would avoid that at all costs?  Why?  We'll there's just so little need for them since there are other ways to relate documents and in XPages you might want to have related documents live in different .NSF files.  I do that a lot.  So response documents would only limit you if you need to spread out to multiple .NSF's.

I do as Bill does.  I use @Unique keys for almost everything.  My reasons for preferring that over the UNID is simply that I've just always used @Unique - even back in the client world.  I just never got into using UNID's that much.  I think it's because I like to have test databases and if I copy documents from production and paste into my test db I want to make sure they work.  Since since the UNID can change in that situation that would stop me from refreshing a test database.

Keep in mind that @Unique() in XPages does NOT give you the traditional format of the Notes Client.  If you want that, which I prefer, you need to do a session - evaluate.  That can work in SSJS and Java.

Definately don't try to reproduce the TableWalker stuff.  Use related documents and repeat controls.  Use related documents like you suggest.

I did a NotesIn9 on this concept a while back.  I've probably done it on a couple shows but this MIGHT be similar to that you're trying to achieve.  http://notesin9.com/index.php/2010/05/12/notes-in-9-018-xpages-data-relationships/

 

Good Luck!!

 

Dave

Jan 9, 2014, 8:18 PM
50 Posts
Thanks for the explanations

I have never used @Unique in that way! In fact, I didn't even know it did that! Wow, how did I ever miss that?

I have used @DocumentUniqueID and stored it in a field and passed it to my "response" documents but I always ran into the problem that I had to save the primary "document" first before I could create the secondary document or "response".

I guess no one out there is going to champion the "documents" and "responses" method for XPages! Wink


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal