Link to home
Start Free TrialLog in
Avatar of darenceang
darenceang

asked on

Checking values against textfield

Hi!
I am very new to lotus notes and was wondering if anyone can help me out with this.
I have a textfield in Notes. (Admin)
There are about 5 email address in the format: USER1/DEVT/SINGAPORE, USER2/DEVT/SINGAPORE etc..

Is there anyway i can do a "split" and compare with another textfield called : CreatedBy?

Of course it has to "loop" through the whole (Admin) textfield.

Please advice.
ASKER CERTIFIED SOLUTION
Avatar of Felix Grushevsky
Felix Grushevsky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of qwaletee
qwaletee

Usually, you can do a simple FIELD1 = FIELD2, even if FIELD2 has a list of names.  That's because Notes compares fields with multiple values against each other, and if there is one corresponding match, then they're considered a match. Examples:

FIELD1 is OneA : TwoB : ThreeC
FIELD2 is TwoA : OneB : ThreeC

Notes evalues FIELD1 = FIELD2 as (OneA = TwoA) _OR_ (TwoB = OneB) _OR_ (ThreeC = ThreeC)
Even though the first two possibilities don't match, the third one DOES match (ThreeC = THreeC) so they are considered a match.

In your case, it is more like:
FIELD1 is User2
FIELD2 is User1 : User2 : User3

When Notes does the comparison, it notices that they are "unbalanced," because FIELD1 has onlyo ne value (FIELD1 is like CreatedBy), while FIELD2 has three values (like Admin). So, in order to make them "matchable," Notes treats FIELD1 as if the value is repeated. So it is as if the values are:

FIELD1 is User2 : User2 : User2
FIELD2 is User1 : User2 : User3

Thus, the comparison is (User2 = User1) _OR_ (User2 = User2) _OR_ (User2 = User3)
The middle one matches, so it is considered a match. If FIELD1 contained the value User4, then the comparison would be:
(User4 = User1) _OR_ (User4 = User2) _OR_ (User4 = User3)
None of those mtach, so it would return false.

As I said, the simple upshot is that you can probably just say:
Admin = CreatedBy

Or,
@If(
  Admin = CreatedBy;
    "The CreatedBy value matches one of the admin values";
   "The CreatedBy value does NOT match ANY of the Admin values"
)

This is called "list processing," a comparison of multivalued (List valued) fields. More complicated compraisons are possible, without resoprting to "split." Note that lists are comparable to arrays, they are not a single string with a separator value, as you might find, in, say, JavaScript procesing of a field value.

If you are using LotusScript, it is treated as a true array, and you can loop over it (For, While, Do, whatever loop construct you fancy), using array subscripts.