Sunday, 22 March 2015

Hiding rows in grid/Scroll Area for specific conditions



Local Rowset &rs;
Local Number &i,&k;
&rs=getlevel0()(1).getrowset(Scroll.YourRecordName);

&i=1; 
&k=0;
&rs.showAllRows();
while (&i+&k) <=&rs.activerowcount

/* Suppose below condition is to hide that particular row*/
if &rs(&i).YourRecordName.FieldName.value="Whatever" Then 
&rs(&i).visible=false;
&k=&k+1;
else
&i=&i+1;
end-if;

end-while;

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;