1

I am new to Domino designer and lotus script,

following my second question,

I have some issue in setting unique ID (for id field in form).

My formula for Id field value :

T_List:=@DbColumn("" : "NoCache"; "Local"; "DBintro";"testview"; 1); @If(@IsNewDoc & @Elements(T_List)=0;1;@IsNewDoc & !@IsError(T_List);@Subset(T_List;1) + 1;id)

I'm having DB in local (nothing shared).

referred this link an Answer by AndrewB

Server : Local

DBname : DBintro

view name : testview id - field in the form (which is set when required to save in DB)

Error I'm getting

Field id ! does not exist

Please help me to get out of this.. Thanks

EDIT :1 Updated code

T_List:=@DbColumn("" : "NoCache"; "Local"; "DBintro";"testview"; 1);
T_List:=@Sort(T_List; [DESCENDING]);
@if(@Iserror(T_List);
  1;
  @Subset(T_List;1)+1
);
Community
  • 1
  • 1
theRoot
  • 571
  • 10
  • 33
  • Hi - where does that error occor ? And when - is it when creating a new document or opening an existing one ? – user2808054 Jan 21 '15 at 17:00
  • It comes when I'm starting IBM notes(preview ) @user2808054 I can't even open the preview – theRoot Jan 21 '15 at 17:16
  • Bad formula. Should be a colon, not semi-colon between servername and filename. Of course, there is no server named "Local". You would just use "" for local. @DbColumn("" : "NoCache"; "":"DBintro";"testview"; 1); – David Navarre Jan 22 '15 at 01:39

4 Answers4

2

Set type of field "testid" to "Number"
Change formula to

_List:=@DbColumn("" : "NoCache"; ""; "testview"; 1);
@If(    @IsError(_List);
            1;
        _List = "";
            1;
            @Subset(_List; 1) + 1
)

Set column sort to "Descending"

enter image description here

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
1

Perhaps re-arranging the logic might help - try this in the formula for Id field. Make the field "Computed When Composed" (next to field typer in properties box - it means it only evaluates when the doc is first created, and remains the same after - saves detecting @IsNewDoc :-D ):

T_List:=@DbColumn("" : "NoCache"; "Local"; "DBintro";"testview"; 1);
@if(@Iserror(T_List);
  1;
  @Subset(T_List;1)
);

You don't have to worry about the id field returning itself if the doc isn't new, because the computed when composed field stops evaluating after 1st save.

user2808054
  • 1,376
  • 1
  • 11
  • 19
  • I want to show the id in form itself, when i'm saving the form I want it to be pushed into DB along with other fields – theRoot Jan 21 '15 at 17:28
  • Is the view "DBIntro" sorted descending on 1st column ? You're getting the forst element in the list so it assumes this. Alternative would be to leave the view unsorted (most recent reated docs go on end of view) and do @Subset(T_List;-1) which gets the last element – user2808054 Jan 21 '15 at 19:10
  • I don't know whether it's in sorted or not, so I go for it :P – theRoot Jan 22 '15 at 11:08
1

Bad formula for your dbColumn. There should be a colon, not semi-colon between servername and filename. Of course, there is no server named "Local". You would just use "" for local. Also, the filename is the full filename - "DBintro.nsf", not "DBintro".

T_List:=@DbColumn("Notes":"NoCache"; "":"DBintro.nsf";"testview"; 1);
T_List:=@Sort(T_List; [DESCENDING]);
@if(@Iserror(T_List);
  1;
  @Subset(T_List;1)+1
);
David Navarre
  • 1,022
  • 10
  • 27
0

Have you got the unique ID set as a text field because I have found that the formula has to be converted to a text value and not just the unique document id.

Jean
  • 42
  • 2
  • 8