Domino on Linux/Unix, Troubleshooting, Best Practices, Tips and more ...

@Transform -- a very powerful Notes formula function

Daniel Nashed  31 May 2018 10:39:57

Notes Formula language is a very powerful part of Notes/Domino which has been around since the first Notes version.
We take it for granted but this is really a key element of the flexibility and RAD we have in Notes.
It's used in forms, views, can be invoked from Lotus Script and even C-API. I am using it every day.
There isn't ,much current training material but it's derived from spreadsheet formula language (this is where actually Notes has it's roots as well).

The @Transform function is very powerful and I don't know why I did not use it for a long time. After I rediscovered it I have used it for views multiple times in a week!

When you work with lists you can only do list operations on the whole list. But if you want to do different operations depending on the element you would need to implement a loop -- which is possible as well in @formulas.
But there is a more convenient function that you can use.

@Transform allows you to operate on each element and build a new list.

The syntax is pretty simple. You provide a list and define a variable that is used in the formula that is executed on each element. The result is a new text list.

Here is a simple example:

mylist:="abc":"edf"; @Transform(mylist; "x"; @if (@Begins(x;"a"); @Right(x;"a"); x))

You can only execute one formula but you can use @Do to group multiple operations if needed.
In a formula I wrote yesterday, I even used a @Transform inside another @Transform.

I had to build a view showing the delegation used in mail-databases based on my own catalog application ("nshdbcat").
Depending on the ACL entry I show the different delegation.
This can be done in a view and it is pretty fast. Rebuild of the view takes a couple of seconds even with 30000 database entries in the catalog.

So if you are working with lists and need flexible operations, @Transform is your friend. I don't know why I forgot about this @function. But it is very usefull!

I have appended the syntax below and my view column formula I build yesterday for evaluating delegation as a more complex example.

-- Daniel

@Transform( list ; variableName ; formula )

list - Text, number, or time-date list. The list to be acted upon.
variableName - Text. The name of a variable. Use this variable in the formula to refer to the list element being acted upon.
formula - Valid formula that evaluates to a result. The remainder of @Transform after the second parameter is the formula that is applied to each element of the input list. The formula must return a value.

Return value- list
Text, number, or time-date. The result of the transformation on the input list. The first value returned by the formula determines the data type of the list. Subsequent return values must be of the same type.

An iteration of the formula can return a list, which adds multiple values to the return list.
@Transform returns an error if any iteration of the formula returns an error.
If an iteration of the formula returns @Nothing, no element is added to the return list.

public:= @Transform (NoAccess; "x";
@If (
@Trim (x) = ""; @Nothing;
@Contains (@Word (x; "|"; 3); "W"); "2. PublicWrite\\"+@Transform(@Word(x; "|"; 1);"z";@If(@Begins (z;"CN="); u; g)+@Name([Abbreviate];z));
@Contains (@Word (x; "|"; 3); "R"); "1. PublicRead\\"+@Transform(@Word(x; "|"; 1);"z";@If(@Begins (z;"CN="); u; g)+@Name([Abbreviate];z));

r:=@Transform(@Word(Reader; "|"; 1);"z";@If(@Trim(z)=""; @Nothing;@If(@Begins (z;"CN="); u; g)+@Name([Abbreviate];z)));
a:=@Transform(@Word(Author; "|"; 1);"z";@If(@Trim(z)="";  @Nothing;@If(@Begins (z;"CN="); u; g)+@Name([Abbreviate];z)));
e:=@Transform(@Word(Editor; "|"; 1);"z";@If(@Trim(z)="";  @Nothing; z=MailFileOwner; @Nothing; @If(@Begins (z;"CN="); u; g)+@Name([Abbreviate];z)));

@If (r="";@Nothing; "3. Reader\\"+ r):
@If (a=""; @Nothing; "4. Author\\"+a):
@If (e=""; @Nothing; "5. Editor\\"+e));
@If (all=""; "-- No Delegation --"; all)


  • [IBM Lotus Domino]
  • [Domino on Linux]
  • [Nash!Com]
  • [Daniel Nashed]