Sequence/Auto Number

I have some parent forms & Child(Response) forms.Now, I’ve been told to build a unique numbering system like 1.01

Where 1,2,3… belongs to Parent doc and 01,02… belongs to child/response doc of a Parent doc.

1.01,1.02…;

2.01,2.02…;

3.01,3.02… so on

Is there any easy/standard/best practice solution?

Thanks in advance.

Subject: Sequence/Auto Number

Try in this way. Create 2 computed when composed fields on parent and response and insert the foll. formulas respectively:

  1. Searial number for Parent docuemnt:

//View vwParent is collection of all parent docs. First column should be the Parent serial Number(sorted) 1,2,3 etc.

listParent:=@DbColumn(“”;“”:“”;“vwParent”;1)

@Subset(listParent;-1)

  1. Searial number for Response docuemnt:

listParent:=@DbColumn(“”;“”:“”;“vwParent”;1)

parentNum = @Subset(listParent;-1)

//View vwResponse is collection of all response documents with Parent number as first column. 1.01, 1.02 etc:

listResponse:=@DbLookup(“”:“NoCache”;“”:“”;“vwResponse”;parentNum;“responseNum”);

responseNum:=@If(@IsError(listResponse);“01”;@Right(“0”+@Text(@TextToNumber(@Right(@Subset(listResponse;-1);“.”))+1);2));

serialNum := parentNum+“.”+ responseNum;

serialNum

Subject: RE: Sequence/Auto Number

And we didn’t even talk about replicas, yet …

Subject: RE: Sequence/Auto Number

or insertions, for that matter.

1.01

← new doc inserted here - what number? In libraries, it would be 1.015

1.02

Subject: RE: Sequence/Auto Number

Thanks SrinivasActually I am trying to use only lookup view for all those parent & child(Response docs) forms.And also using number fields to actually deal with the process but a display field to format the way I want.

No success yet.

Number should always increment, no matter if some are deleted from the middle.

No replica issues.

Can someone please help me…?

Subject: Sequence/Auto Number

Has anybody thought about what should happen, if documents or responses are deleted?

There is of course @DocNumber, but it is intended to be used in column formulas and window title formulas. It kind of works in computed fields as well, but this additional computation is rather useless, as storing the number in the document provides no additional value: DocNumber is alway calculated dynamically. It should work in computed for display fields or computed text as well.

Apart from how to deal with deletions (doc number will always be calculated to display the actual number in the view) there is another problem. The numbering depends on the view displaying the documents. If another view is designed differently, there may be other and/or additional numbers. Also there is no way to introduce the leading zero.

If you choose to calculate numbers yourself, the first thing you have to know is how changes to the document hierarchy should be handled. You need a definite, detailed, written description of what should be achieved. Your code would depend a great deal on what is to be achieved exactly.

Subject: Sequence/Auto Number

Just to give yo idea. usually what i did was storing parent id inside the child. the id must be unique enough this way child will always linked to teh parent. in term of numbering system you must have 2 sets to keep track. one for the parent and another one is for the child. Do not use the numbering as the id.

Anyway there should be a lot of example in lotus notes template. HAve a look at the discussion type template.

Subject: RE: Sequence/Auto Number

Hi

Why do you want to store the parent unid in the child ? Ain’t the $REF field sufficient ?

rgds