Posted by: Patrick | March 9, 2008

New Reference


Another “why-I-haven’t-I-thought-of-that-before” idea I encountered during the past week was when I had to force a response document to access its parent when it’s still new. Even if it still hasn’t been saved yet, it has to be able to get the corrent document unique ID of its parent. It sounds easy with the use of the @InheritedDocumentUniqueID but everything gets messed up once the document is saved.

A common workaround found in the Notes.net forums is to have 2 fields provide the needed values. That is, one field will have the value of @InheritedDocumentUniqueID and is to be used when the document is new, and the other field is to have the value of $REF and is to be used for existing documents. Since two fields to be maintained for a single purpose, I went out my way to find out if someone already came up with something neater.

Within a few minutes, I came across an astute solution. Derek Papworth’s solution outlines two steps:

  1. Create a new computed when composed field named $REF.
  2. Set the field’s formula to @InheritedDocumentDocumentUniqueID.

It’s easy as that. Thinking about it, the solution does make sense and the only difference it has is that it has that “why-I-haven’t-I-thought-of-that-before” ingredient typical of great solutions. As Derek wrote:

when a doc is first created $REF is there and set and can be used and when it’s saved all well and there’s no extra redundant field .. all formulas/script can now refer to $REF at ANY time without worrying about @IsNewDoc etc.

Right now I’m going with it as everything seems to work as expected after some tests using the approach–agreeing with both Stan Rogers and Scott Leis’ subsequent comments.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: