Hi , Does anyone knows is there any way to loop every column in selected row ? For example .. I set a filter to get Sales Line by Sales Header No. I want to loop every fields value and column name which selected row . The code just like ..
SalesLineRec.RESET;
SalesLineRec.SETFILTER("Document No",SalesHeaderRec."No.");
IF SalesLineRec.FINDFIRST THEN
REPEAT
...
( just like those code which i want to do )
Foreach ( DataRows Col in SalesLineRec.Rows )
if (Col="ItemNo" )
Do something
Loop
...
UNTIL SalesLineRec.NEXT=0;
0
Answers
if Contact.findset then
repeat
recRefp.GETTABLE(Contact);
FOR i := 1 TO recRefP.FIELDCOUNT DO BEGIN
fldRef := recRefP.FIELDINDEX(i);
IF FORMAT(fldRef.CLASS) = 'FlowField' THEN
fldRef.CALCFIELD;
IF fldRef.NAME IN THEN BEGIN
IF i = 1 THEN
lineLBtx.ADDTEXT('')
ELSE
lineLBtx.ADDTEXT(STRSUBSTNO(';%1',''));
END ELSE BEGIN
IF i = 1 THEN
lineLBtx.ADDTEXT(fldRef.VALUE)
ELSE
lineLBtx.ADDTEXT(STRSUBSTNO(';%1',fldRef.VALUE));
END;
END;
until Contact.next <= 0;
I will first a a comment, never do a findfirst and thereafter a repeat, you are asking the SQL server two times :-)
Now to your question, you can do this by looping on the table Field and using recordref and fieldRef:
MasterRecRef.OPEN("Tabel ID",FALSE);
Field.RESET;
Field.SETRANGE(TableNo,"Table number");
Field.SETRANGE(Enabled,TRUE);
Field.SETRANGE(Class,Field.Class::Normal);
IF Field.FINDSET THEN
REPEAT
FieldRef := RecRef.FIELD(Field."No.");
//Do Stuff with fieldRef
UNTIL Field.NEXT = 0;
When I use the FieldRef to get record filed vaule or field name it works fine . But I get 0 when the filed is FlowField in record . For example , The Amout Filed is FlowField in Sales Header. It returns always 0 when I use the fieldRef.
How could I do ? Do you have any ideal ?
IF FORMAT(fldRef.CLASS) = 'FlowField' THEN
fldRef.CALCFIELD;
Yeap, you are right. It seems need to check the filedref.CLASS and CALCFIELD, before to read fieldRef.value. And then it woks fine.
thanks for your help .