Is there any way to loop every column in selected row?

vinceliu666
Member Posts: 51
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;
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
Best Answers
-
Found something for you, hope it helps:
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;5 -
Hi @vinceliu666,
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;For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.6 -
Doen't this work?:
IF FORMAT(fldRef.CLASS) = 'FlowField' THEN
fldRef.CALCFIELD;5
Answers
-
Found something for you, hope it helps:
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;5 -
Hi @vinceliu666,
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;For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.6 -
Thanks for your help very much.0
-
Hi SanderDk and TallyHo
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 ?0 -
Doen't this work?:
IF FORMAT(fldRef.CLASS) = 'FlowField' THEN
fldRef.CALCFIELD;5 -
Hi , TallyHo:
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 .0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions