Subject: Show data in a view column
On the principle that teaching a man to fish and then giving him a fish to tide him over until he catches one is probably the best way to go about solving the hunger problem…
You have a couple of options in formula language to attack the problem. One is old-school, and will work in any version of Notes/Domino. The other is new with Notes and Domino 6. We’ll do the old-school version first, since working list-wise can get an awful lot done with a very little code once you’ve started thinking in lists.
You have a bunch of text values that can be identified by what they end with, and you only want to keep values that have one of the possible endings:
“aa@gmail.com”
“ab1@aa.com”
“cc@gmail.com”
“123@g.com”
Let’s call that list FieldName for the time being (since that’s where it’s coming from, and it’s easy to substitute the actual field name into the formula later). You are only interested in the Gmail addresses. If you do this:
tempList := @Leftback(FieldName; “@gmail.com”);
you’ll wind up with a list containing these values:
“aa”
“”
“cc”
“”
Note that you need to check for the whole string “@gmail.com”, otherwise addresses ending in something like “@kingmail.com”, which also ends in “gmail.com”, would also be selected. You then trim the list – that is, remove any values that are the empty string:
tempList := @Trim(tempList);
which will leave you with:
“aa”
“cc”
Now, there is a chance that NO Gmail addresses were in the original list, so the whole value of the list at this point may be “” (which is what @Trim will return if there’s nothing else to return). That means that you have to check the list for empty. If it is NOT empty, then adding “@gmail.com” to the list will add @gmail.com to every member of the list.
@If(tempList = “”; “”; tempList + “@gmail.com”)
You can put the first two steps together, giving you:
tempList := @Trim(@Leftback(FieldName; “@gmail.com”));
@if(tempList = “”; “”; tempList + “@gmail.com”)
That will give you a list containing:
“aa@gmail.com”
“cc@gmail.com”
That’s the old method. As of Notes and Domino 6, you have the @Tranform function at your disposal, which will allow you to do some more sophisticated kinds of filtering. Again, we’ll use FieldName as the name of the source.
@Transform(FieldName; “x”; @If(@Ends(x; “@gmail.com”); x; @Nothing))
The “x” is the name of the temporary variable that @Transform is going to use for each member of the list. If the member ends with “@gmail.com”, it is kept; if it doesn’t, then it is replaced with @nothing, which is no value AND doesn’t add a member – not even an empty member – to the new list. To make that just a little bit “safer” (that is, to keep your users from seeing any scary error messages in the view column), you would write that formula as:
tempList := @Transform(FieldName; “x”; @If(@Ends(x; “@gmail.com”); x; @Nothing));
@If(@IsError(tempList) | tempList = “”; “”; tempList)