How to write all values from field in the variable?

MarharytaMykytenko
Member Posts: 53
I have a variable which have to show all values from field of table (this is NOT a Source table, so SourceTempTable property on my page is set to 'YES'). But my variable show only latest value from the field of table in all records that it represents.
I have this code on my page in OnAfterGetRecord() trigger
currReq:= Rec."Request No.";
po_l.SETCURRENTKEY(po_l."Purchase Request No.",po_l."Document Type");
po_l.SETRANGE(po_l."Purchase Request No.",currReq);
po_l.SETRANGE(po_l."Document Type",po_l."Document Type"::Order);
IF po_l.FINDSET THEN BEGIN
repeat
begin
AmountToBeInvoiced:= po_l."Amount to be Invoiced";
END;
UNTIL po_l.NEXT = 0;
END;
And my result is next:

Any ideas??
p.s: po_l - record variable of a table (not Source table)
I have this code on my page in OnAfterGetRecord() trigger
currReq:= Rec."Request No.";
po_l.SETCURRENTKEY(po_l."Purchase Request No.",po_l."Document Type");
po_l.SETRANGE(po_l."Purchase Request No.",currReq);
po_l.SETRANGE(po_l."Document Type",po_l."Document Type"::Order);
IF po_l.FINDSET THEN BEGIN
repeat
begin
AmountToBeInvoiced:= po_l."Amount to be Invoiced";
END;
UNTIL po_l.NEXT = 0;
END;
And my result is next:

Any ideas??
p.s: po_l - record variable of a table (not Source table)
0
Best Answer
-
Perhaps, you just need to add filter on Line no.
po_l.SETRANGE("Line No.",po_l."Line No.");
5
Answers
-
AmountToBeInvoiced+= po_l."Amount to be Invoiced";0
-
AmountToBeInvoiced+= po_l."Amount to be Invoiced";
Hi
this line of code will work next way: the first record "Amount to be Invoiced"=10 will be find and set in AmountToBeInvoiced as first value; and the second value will be 20=10+10, third 30=20+10, etc.
But I have to get all values from field of table "po_l" and write them to the variable "AmountToBeInvoiced"0 -
Couldn't you make your "Amount to be Invoiced" a flowfield on your "Purchase Request" (I'm guessing) table? It could point to Purchase Header table with CONST(Order) on "Document Type" field and FIELD (Request No.) filter on "Purchase Request No." field. That way you wound't need to do any calculations manually.0
-
Couldn't you make your "Amount to be Invoiced" a flowfield on your "Purchase Request" (I'm guessing) table? It could point to Purchase Header table with CONST(Order) on "Document Type" field and FIELD (Request No.) filter on "Purchase Request No." field. That way you wound't need to do any calculations manually.
Hi,
I do not have to make calculations. I just want to copy values from field of po_l table to the variable on my page0 -
Hi,
If there are two line in PO_l table than you want to display "10, 20" in this field, right?
10 is amount from the first record and 20 from the second.
0 -
Hi,
If there are two line in PO_l table than you want to display "10, 20" in this field, right?
10 is amount from the first record and 20 from the second.
Hi,
No, post with values 10 and 20 was just explanation for AK why his line of code will show incorrect result.
Ok, lets imagine that I have next values of table (for example it have "Order Line" name) field:
1
2
3
4
10
And I have a page (for ex. it have "My table list" name) with fields from source table (for ex. source table name is "My table" name). On this page I have a field named "AmountToBeInvoiced", so I want to fill this field with values from "Order Line" table:
1
2
3
4
10
Above way to do this by code was represented. But I have no idea why my code does not work and "AmountToBeInvoiced" field is filled by the same value0 -
Perhaps, you just need to add filter on Line no.
po_l.SETRANGE("Line No.",po_l."Line No.");
5
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
- 320 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