Showing posts with label lotus formula. Show all posts
Showing posts with label lotus formula. Show all posts

Tuesday, April 20, 2010

open view into another database using outline

If you want to open view form another database into current one using outline -> use URL approach.
here is short instruction:
- open property of your outline an select one Entry
- select type URL and make result like this:
"notes://" + @Name([CN]; @ServerName) + "/" + DBReplicaID+ "/" + "myview?OpenView"
- do not forget to choose Frame (target)

This is actually very easy but some people asked me long time ago how to do that, so I would like to share this and help to anybody.

Wednesday, December 02, 2009

Re-open document using @Formula

Need to update document using re-open approach?

here is easy way:
@Command([SwitchForm]; currentForm)

I like this approach, especially because I've never thought about such way.

Tuesday, November 03, 2009

How @UserAccess can determine No Access level?

One my fellow asked me how to determine that user don't have access to database using only @formula. So I want to share how it can be done.
We should just check it on @IsError(@UserAccess(..)) and it will return 1 for cases if you don't have access to database at all.

Saturday, December 20, 2008

Debug Lotus Notes applications

I would like to present which approaches I use during debugging LN applications. I would be happy if anybody add new interesting approaches.


- @Prompt and @StatusBar – the easiest way to debug code written on @Formula
- Field Debug_Fld := value_debug
- @MailSend – for code that runs on server (sch. agents)
- notes.ini - I don't like this approach because of size of variables

strA := "ABC"; strB := "DEF";
strC := strA + strB;
@Prompt([ok]; "strC";"strC = " + strC);
@StatusBar("strC = " + strC);
Field Debug_FieldName := strC;
@MailSend("username";"";""; "debug strC"; ""; "strC = " + strC);

[Lotus Script]
- Lotus Script Debugger as tool for debugging
- Print, MsgBox, NotesLog, Stop, on erorr goto errh

Dim strA As String
Dim strB As String
Dim strC As String
strA = "ABC"
strB = "DEF"
strC = strA & strB
Print "strC = " & strC
Msgbox "strC = " & strC
Stop 'enable debugger require
Dim currentLog As New NotesLog( “debug log 1" )
Call currentLog.OpenFileLog( "c:\log.txt" )

Call currentLog.LogAction( "strC = " & strC)
Call currentLog.Close

[Schedule Agents]

- remote debugger (it is easy to enable it if you read help)
- send an email, msgbox (log.nsf), noteslog

- alert(value);
- try – catch();
- Microsoft script debugger \ Mozilla firebug \ Chrom debugger

Lets catch the next simple error

code on the button use call function add, the body of function below
function add(frm){
var i1 = frm.Number1.value;
var i2 = frm.Number2.value;
var fld =;
fld.value = i1 + i2;

when we call function we will see next error:
what it could be? it does not provide us enough information (I think so). Now enable ie debugger
click Yes
Now we see where is error, but still could not understand "why?"
Now we are definitely close to solve the problem, we see that we did not take "number" field. Why we did not take number field? yes because of small first letter. We should wrote Number but not number.

- Java debug console (System.out.println(“text”);
- Try / catch with NotesError and NotesException classes
- Remote java debugging with Eclipse

also I would like to recomend you external LN application

Tuesday, September 16, 2008

how we can remove temporary fields from document

Set a computed field in the bottom of the form with next formula:

@If(@IsDocBeingSaved; @Success; @Return(""));
@SetField("Field1"; @DeleteField);
@SetField("Field2"; @Unavailable);

It is very simple and useful solutions as for me and to be honest I did not find any better way

Thursday, February 07, 2008

Decimal Separator in formula - Solution

definetly it is a simple feature, but I like such approaches, I found this one on IBM:
@Middle(@Text(@Pi); 1; 1)
but probably this one will be more easy for our brain (but it depends):
@Middle(@Text(1/10); 1; 1)

Actually the problem could be when we want to show value which are stored in 2 (or more) different fields, put them together in 1 place and split "default decimal symbol".

default decimal symbol - could be changed in Control Panel->Regional Options->Numbers tab.

Tuesday, January 08, 2008

compare arrays

I've seen many different functions which compare arrays, so I've decided to write my variant of this function. I suppose my function much simpler.

here is the script o function

Function ArraysAreEqual (vA As Variant, vB As Variant) As Variant

Dim rez As Variant

rez = Evaluate({@implode(@sort(@Explode("} & Join(vA, "~") & {"; "~")); "~") = @implode(@sort(@Explode("} & Join(vB, "~") & {"; "~")); "~")})

If rez(0) = 0 Then ArraysAreEqual = False Else ArraysAreEqual = True

End Function

advantages of my approach:
- more simple, just 1 line;
- faster;
- we can compare any number of arrays

but any advices will be appreciate! especially disadvantages !

Thursday, September 06, 2007

how will be right to hide fields

Usually, developers Lotus Notes, write the hidden formula directly in every paragraph... But I recommend to write all hidden formulas in one field. So, this special field will contain all fields which you need to hide. So in paragraph you will need only write something like this:
hiddenFld = "NameOfField".

Of course, you can use the same idea for validations all necessary fields.

Just try it and I think you will like it :)

Tuesday, August 28, 2007

Document values "changer"

I'm sure that every Lotus Notes developer during debugging has problems with changing values of fields. So I want to show a code which will help you (I hope) in this. Just try it !

(author is here

REM {Get a listing of all the fields on the current document};
List := @DocFields;

REM {Possible data types to choose from.};
REM {I called Number Integer because use keyboard to select what you want with keyboard quicker.};
DataTypes := "Text" : "Date" : "Integer" : "Password" : "Name" : "Common Name" : "**** Remove Field ****" : "Text Multi Value" : "Date Multi Value" : "Integer Multi Value" : "Name Multi Value";

REM {Prompt for which field needs to be updated.};
EditField := @Prompt([OkCancelList]; "Select Field To Update"; "Select the field you wish to update:"; ""; List : "**** ADD A NEW FIELD ****");

REM {If adding a new field, prompt for the field name};
NewFieldName := @If(EditField = "**** ADD A NEW FIELD ****"; @Prompt([OkCancelEdit]; "Enter Field Name"; "Enter the name of the new field:"; ""); "");
CheckFieldName := @If(@IsMember(NewFieldName; List) & NewFieldName != ""; @Return(@Prompt([Ok]; "Already In List"; "The field " + NewFieldName + " already exists on the document.")); "");
UpdateVariable := @If(NewFieldName = ""; ""; EditField := NewFieldName);

REM {Prompt for which data type you would like the data to be};
REM {This needs to be done before value prompt to determine if the};
REM { Picklist or any prompting needs to be used.};
DataType := @Prompt([OkCancelList] : [NoSort]; "Choose Data Type"; "Please Select the correct data type or action for field: " + EditField; "Text"; DataTypes);

REM {For multi-valued fields, let the user choose the separator to use};
Separator := @If(@Contains(DataType; "Multi Value"); @Prompt([OkCancelList] : [NoSort]; "Choose Separator"; "Choose the separator to split out your multiple values"; ":"; (":" : ";" : "+" : "-" : "*")); "");

REM {Pull out the current value of the field};
CurrValue1 := @Eval(@Text(EditField));
CurrValue2 := @Abstract([TextOnly]; 254; ""; @Text(EditField));
CurrValue := @If(@IsNumber(CurrValue1) | @IsTime(CurrValue1); @Implode(@Text(CurrValue1); Separator); CurrValue2 != ""; CurrValue2; @Implode(@Text(CurrValue1); Separator));

REM {Based on what type of data is being entered different prompts will happen if any at all.};
RawValue := @If(
@Contains(DataType; "Name Multi Value"); @PickList([Name]);
@Contains(DataType; "Name"); @PickList([Name] : [Single]);
DataType = "**** Remove Field ****"; "";
@Contains(DataType; "Multi Value"); @Prompt([OkCancelEdit]; "New Value"; "Please enter the new desired value for: " + EditField + " seperated with " + Separator + " for each value."; CurrValue);
@Prompt([OkCancelEdit]; "New Value"; "Please enter the new desired value for: " + EditField + "."; CurrValue)

REM {If data conversion doesn't work then don't set field.};
DataType = "Date"; @If(@SetField(EditField; @TextToTime(RawValue)));
DataType = "Integer"; @If(@IsError(@TextToNumber(RawValue)); ""; @SetField(EditField; @TextToNumber(RawValue)));
DataType = "Password"; @SetField(EditField; @Password(RawValue));
DataType = "**** Remove Field ****"; @SetField(EditField; @DeleteField);
DataType = "Text Multi Value"; @SetField(EditField; @Explode(RawValue; Separator));
DataType = "Date Multi Value"; @SetField(EditField; @TextToTime(@Explode(RawValue; Separator)));
DataType = "Integer Multi Value"; @If(@IsError(@TextToNumber(@Explode(RawValue; Separator))); ""; @SetField(EditField; @TextToNumber(@Explode(RawValue; Separator))));
DataType = "Name Multi Value"; @SetField(EditField; @Explode(@Name([Canonicalize]; RawValue); Separator));
@SetField(EditField; RawValue)