Tag Archive: @Formula

Stop Using Today in View Selection Formula

During my recent session at Lotusphere, I briefly mentioned NOT using @Today in view selection formula (because it’s a big hit on performance). I didn’t have time to get into possible solutions, but did mention the SelectionFormula property in LotusScript. Some of you asked for more details. Silly me, I had completely forgotten I’d written about it in my first article for Lotus User Group’s Lotus Developer Tips Newsletter.

Please see that article for details! And thanks for attending the session!

Round and Round

So the other day I discussed @Transform. While @Round may not transform your life, it is important to know about.

Us application developer types may not be numbers people. And Lotus Notes isn’t exactly known for its number functionality. You probably aren’t calculating complex mathematical equations in your Notes applications. However, even if you are calculating simple calculations, you need to know about @Round.

Note that:

3.3 * 3.3 = 10.89

and

3.33333 * 3.33333 = 11.11

No big deal, right? Except if these calculations are on a much larger scale. And if they are compounded by further calculations on the results.

Enter @Round

Determine where the decimal place should go, and apply it consistently with @Round.

@Round (value, factor)

@Round (10.555, 0.1) = 10.6

Note that the syntax for the LotusScript method Round is slightly different. The second parameter is simply the number of digits after the decimal place, not a factor. In LotusScript, Round (10.555, 1) = 10.6.

Transform Yourself or At Least Your Code

I think @Formula is a frequently forgotten art of Lotus development. Many people start out learning @Formula, then move on to LotusScript and don’t look back. That can be a mistake as @Formula can sometimes be more efficient than LotusScript. There are @functions that just don’t exist in LotusScript, or require fewer lines of code, or take more parameters.

Today I bring you @Transform. @Transform can be used to transform a value, or even better, a list of values. Take for example a list of user-entered values. The values were supposed to be in percentages. Some users entered “50″ meaning 50% and others entered “0.50″ also meaning 50%. How can we take the list of values and only change those that were in the incorrect format? @Transform, of course!

We’d like to show all of our values in decimal format, so all we need to do is use the following code:

@Transform (valueList; “x”; @If (x>1; x/100; x) )

This translates into: for each value in “valueList”, which we will call “x”, if that value is greater than 1, then divide it by 100, otherwise, leave it as is.

Another example is my running log. Say we would like to transform all the values in a list of running times from minutes to seconds. But again, we are concerned that some users may have already entered the data in seconds. TRANSFORM! (Picture me like Harry Potter with my wand when you read that).

@Transform (valueList; “x”; @If (x<60; x*60; x) )

This formula assumes that if the user entered a value greater than 60 then they must have entered the value in seconds, not minutes.

As with many @Functions, you are only limited by your imagination and creativity in coming up with ways to utilize the formula. Any formula can be used as the third parameter in @Transform, including @Nothing:

@Transform (valueList; “x”; @If (x<60; x*60; @Nothing) )

Similar to the previous examples, but returns nothing for a value if the value does not meet the criteria, effectively removing the value from the list.

Happy Transforming!