Accessing Reserved FieldsAlthough we prefer to use the "GetItemValue" method of the NotesDocument object to retrieve a field value, we know that many developers prefer to use the extended syntax to retrieve a field value. If you aren't familiar with the extended syntax, these two statements are equivalent:
result = doc.GetItemValue("MyField")(0)
result = doc.MyField(0)
The true difference between the above statements is performance. The first line will be slightly faster than the second line. In the first line, the LotusScript interpreter knows that "GetItemValue" is a method so it immediately finds the method and runs it. The second line looks to the interpreter like a property, so it tries to find the property. When that isn't found, it says, "oh, it must be a field" and then finds the field. So the first statement is just a little faster. One trial we did ended up with a 4% time savings, but that's not the point of this tip.
If you still would like to use the extended syntax, and have a need to access some reserved fields (like $UpdatedBy or $Ref), if you try to put this statement in your script:
result = doc.$UpdatedBy(0)
The compiler will immediately give you an error:
Unexpected: $UpdatedBy; Expected: Identifier
To access a reserved field with the extended syntax, there's a little trick you can use:
result = doc.~$UpdatedBy(0)
The tilde character in front of the dollar sign satisfies the compiler and the interpreter knows to ignore that tilde when it's going through the code. So it gets the "$UpdatedBy" field off the document.