Writing a function once and then using it in many places is easy to do when you use LotusScript -- but what about @formula's? In Notes 6 you can do this for @formula's as well.
The following example has a date formatting formula, stored in one location and used in different places. It formats a date value as "2005/03/04 Friday."
- Create a shared, computed for display text field named DateFormula. Paste the following code in this field (include the braces!)
{
@Text(@Year(tmpDate)) + "/" +
@Right( "00"+ @Text(@Month(tmpDate)); 2) + "/" + @Right( "00"+ @Text(@Day
(tmpDate)); 2) + " " + @Select( @Weekday
(tmpDate); "Sunday"; "Monday"; "Tuesday"; "Wednesday"; "Thursday"; "Friday"; "Sa
turday") }
- Insert the shared field on your form and make it hidden for Notes and the Web.
- If you have two date fields on your form named DateA and DateB. Add computed text (or a computed for display text field) to your form containing the following formula:
tmpDate := DateA;
@Eval(DateFormula)
And for the formatting of field DateB of course:
tmpDate := DateB;
@Eval(DateFormula)
Notice that tmpDate is actually a temporary variable in your formula which is referenced in the shared field code! So this works like a parameter for your @Formula function. There are lots of other possibilities to use this like input translations/validations, buttons and so on.
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Rob Van Den Heuvel. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.