This simple formula is used for generating sequential numbering of fields in the document.
1. Create a form which has a field called SequenceNumber
2. Create a view called Sequence with only one column Sequential number which has its value from the field SequenceNumber
3. Use the below code for SequenceNumber Computed Field
getval := @DbColumn("":"NoCache";"":"";"Sequence";1); @If(@IsNewDoc;@If(@IsError(getval);1; @Subset(getval;1) = "";1;@Subset(getval;-1)+1); @IsNewDoc;"";SequenceNumber)