How to write all values from field in the variable?

MarharytaMykytenkoMarharytaMykytenko Member Posts: 53
edited 2020-02-28 in NAV Three Tier
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:
hcqin38xoodr.png
Any ideas??

p.s: po_l - record variable of a table (not Source table)

Best Answer

Answers

  • AKAK Member Posts: 226
    AmountToBeInvoiced+= po_l."Amount to be Invoiced";
  • MarharytaMykytenkoMarharytaMykytenko Member Posts: 53
    edited 2020-02-28
    AK wrote: »
    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"
  • ShaiHuludShaiHulud Member Posts: 228
    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.
  • MarharytaMykytenkoMarharytaMykytenko Member Posts: 53
    ShaiHulud wrote: »
    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 page
  • AlexDenAlexDen Member Posts: 85
    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.
  • MarharytaMykytenkoMarharytaMykytenko Member Posts: 53
    edited 2020-02-28
    AlexDen wrote: »
    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 value
Sign In or Register to comment.