« Happy new year .. | Main| Ext examples fixed »

Comparing Notes items - .equals method

Category
Bookmark : del.icio.us  Technorati  Digg This  Add To Furl  Add To YahooMyWeb  Add To Reddit  Add To NewsVine 


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.

    A picture named M2

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

Gravatar Image1 - Excellent many thanks for this - will defo add it to what i have been working on.
Will download the code tomorrow so expect a call ;)Emoticon

Gravatar Image2 - Scott, excellent ! There's definitely a huge need for such a function. Here's a glitch that you may want to plan for, it's possible to have multiple items with the same name, which are *not* accessible simply by using GetFirstItem.

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

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

Welcome ..

View Scott Cochrane's profile on LinkedIn

My IdeaJams

tag cloud

MiscLinks

Googles

  • No Search Referers

OpenNTF

Poweredby

Domino BlogSphere
Version 3.0.1 Beta 9