Comparing Notes items - .equals method
Category LotusScript
Bookmark :
A friend of mine had been wanting to compare 2 fields on documents. I pointed out that java/.net objects have an implementation of the equals method which provides an easy way to compare 2 objects. This would work like:
obj1.equals( obj2 )
This will return true if the 2 objects are equal (what determines that an object is equal depends on the object). So I thought it would be nice if you had a LotusScript NotesItem object that provided an equals method. So I've written the xNotesItem class that wrappers a NotesItem class an provides an equals method.
I haven't filled out the rest of the methods but it should be useful enough if you need to compare items.
I've briefly tested this with Text, Number, Date/Time and Rich-text items and it should also handle multi-value fields. The criteria for equal is really just that the string value of the item is the same. For Rich-text, formatting and attachments are ignored, it just compares the plain text value. For multi-value items it is also required that the Item have all the same values in the same order.
I've included this in a database {link} with a little testing agent and a couple of documents if you want to try it out. Well I know of at least one person that should find it useful, I hope someone else does to.
Bookmark :
A friend of mine had been wanting to compare 2 fields on documents. I pointed out that java/.net objects have an implementation of the equals method which provides an easy way to compare 2 objects. This would work like:
obj1.equals( obj2 )
This will return true if the 2 objects are equal (what determines that an object is equal depends on the object). So I thought it would be nice if you had a LotusScript NotesItem object that provided an equals method. So I've written the xNotesItem class that wrappers a NotesItem class an provides an equals method.
I haven't filled out the rest of the methods but it should be useful enough if you need to compare items.
I've briefly tested this with Text, Number, Date/Time and Rich-text items and it should also handle multi-value fields. The criteria for equal is really just that the string value of the item is the same. For Rich-text, formatting and attachments are ignored, it just compares the plain text value. For multi-value items it is also required that the Item have all the same values in the same order.
I've included this in a database {link} with a little testing agent and a couple of documents if you want to try it out. Well I know of at least one person that should find it useful, I hope someone else does to.
- 







Comments
Will download the code tomorrow so expect a call ;)
Posted by James Allen At 22:43:20 On 06/01/2008 | - Website - |
I have a version of this that allows for comparing (order sensitive or not), that accounts for multiple items with the same name. It's ugly, really ugly :) It pulls all the values into an array from all the instances of the item... then compares those.
Just something to think about, thanks for sharing !
Dave Taylor
Posted by DaveT At 21:52:13 On 25/09/2008 | - Website - |