Dynamics Nav FlowField 和 Calcfild

Dynamics Nav FlowField and Calcfild

我想从客户 table 中提取余额(流场)记录到账单 Table。我有一个客户 table 和一个 BillPros table。 客户中的余额table是一个流场。

//Customer on Variable Band Billing
Customers.RESET;
Customers.SETCURRENTKEY(Customers."No.");
Customers.SETFILTER(Customers."No.",'%1',MeterR."Customer Number");
Customers.SETFILTER(Customers."Customer Posting 
         Group",'%1',Surcharge."Customer Posting Group");
Customers.CALCFIELDS("Balance (LCY)");
Bal := Customers."Balance (LCY)";

IF Customers.FIND('-')THEN 

   //Post Metre Reading;
      PostReading.RESET;
      PostReading.Date := MeterR.Period;
      PostReading.MetreID :=MeterR."Metre ID";
      PostReading."Last Reading" := MeterR."Metre Reading";
      PostReading.INSERT;



      //Bill Info Process
      TotalAmount:=0;
        BillPros.INIT;
        BillPros."Customer No." := MeterR."Customer Number";
        BillPros.Consumption := TotalReading;
        BillPros.Rate := Bands."Rate Amount";
        BillPros."Invoice No." := MeterR."Invoice Number";
        BillPros.Amount := TotalReading*Bands."Rate Amount";


        BillPros.Balance := Bal;

您的代码有误。您应该在 FIND('-') 之后调用 CALCFIELDS。在此之前,您 "don't have" 实际的客户记录。而且您不需要 Bal 变量。你可以这样写 BillPros.Balance := Customer."Balance (LCY)";