Monday, 2 March 2015

Generating new sequence number while inserting new row in a grid/Scroll area.

Write the below code in row insert or row init event (preferably in row insert) of the record peoplecode or the record field peoplecode.
Local Rowset &rs;
Local number &max;
&rs=getlevel0()(1).getrowset(Scroll.YourRecordName);

rem Below loop is to find the max sequence number in your grid;
&max=0;
for &i=1 to &rs.activerowcount
 if &max<&rs(&i).YourRecordName.SEQNBR.value then
&max=&rs.YourRecordName.SEQNBR.value;
end-if;

end-for;

rem Assigning Sequence number to the new row;

if none(&rs(CurrentRowNumber()).YourRecordName.SEQNBR.value) then
&rs(CurrentRowNumber()).YourRecordName.SEQNBR.value=&max+1;
end-if;

No comments:

Post a Comment