Sum table field without flow field

I need to sum a field real time, where Center No is M-150.
I need to do it without flowfield.

I make this, but gives me only 0 as result.

Routing Line table → new field → Sum M-150 as decimal field
Routing Line table → new funcition → SumTotal150
Variables for this funcion → RoutLine, datatype is record, subtype is Routing Line


RoutLine.SETCURRENTKEY(“Routing No.”, “Work Center No.”);
RoutLine.SETRANGE(“Routing No.”,“Routing No.”);
RoutLine.SETRANGE(“Work Center No.”, ‘M-100’);
RoutLine.CALCSUMS(“Real Time”);

Save this result.

I go to my new field Sum M-150 on validate() and place there name of the function like this → SumTotal150;

Result is everything 0

Where do I make a mistake?


What Datatype is “Real Time”. What version of Dynamics? and have you tried CALCFIELDS(“Real Time” ) instead?

Depending of your NAV version the CALCSUMS only works if you on you key “Routing No.”, “Work Center No.”) - have added a SUM-field to the index.

You should take a look at the Customer table and one on of the flowfields and then the corresponding Customer Ledger Entry.

The question you are asking is very basic, and you could take a look at the NAV 2013 Training material C/Side Introduction. It will speed up your learning curve dramatically.

Real Time is Decimal
Navision 2009 R2
Calcfields still not working

Where you are saving the result and how?

Everything is in table Routing Line

Could you paste 3 records into this message. Because you are doing something basically wrong and just to verify that you have the data correctly

seems you are calsuming but not saving - do what [mention:74275055534c437ab13054c27a1ed5fb:e9ed411860ed4f2ba0265705b8793d05] suggested

Take a look at this example

CustLedgerEntry.SETCURRENTKEY(“Customer No.”,“Posting Date”,“Currency Code”);
CustLedgerEntry.SETRANGE(“Customer No.”,‘10000’);
CustLedgerEntry.CALCSUMS(“Sales (LCY)”);
MESSAGE(FORMAT(CustLedgerEntry.“Sales (LCY)”));

  • The sortingkey used has a SUMINDEXFIELD

Besides you wrote M-150 but your code says

RoutLine.SETRANGE(“Work Center No.”, 'M-100’);

my new field in Routing Line

My function in Routing Line

Field Sum M-100 OnValidate()

Routing No. Work Center No. Real Time Sum M-100
700010 M-100 108 0
700010 M-100 44,25 0
700010 M-100 0 0
700010 M-100 6,25 0

Look at example Palle suggested. Still cant figure out where you are saving the value there is no code for it. You are not doing anything with returned value even it is calculated correctly. I believe you are trying to save values to Sum M-100 field onvalidation? so if you vaildate on this field for all four records you will have sames value in each record. does not seem to be efficient and logical unless you have other plans with it.

Thankyou for showing your code. But it is wrong in so many ways (sorry)

  1. Why do you create a SumTotal100 Function?
  2. What is the the purmose of the Sum M-100 field?
    3 You don’t use the calculated “Real Time” field

It seems to me that you are very new at programming and you are missing some VERY important things about the C/AL Language. You REALLY NEED to participate in a training class or at least read the training material C/Side Introduction and C/Side Solution Development.

Try adding a line after your Routline.CALCSUMS(“Real Time”) - and see what happens.

MESSAGE(FORMAT(RoutLine.“Real Time”);

I’m sure about that I’m newbie.
I’m new at c/al. So I learn everyday something new.

  1. I was thinking about to create a function to sum this filtered field.
  2. My idea was to put there the function and store the value for the field in my table.
  3. I don’t understand that.

Thanks for the time, you are good man.

Sorry mate, you have to read the training material C/Side Introduction and C/Side Solution Development if not attending a training class!

Currently you are not learning to code in C/AL - you’re just punching some lines of code that you do not know how to work with.

You can access material here at customersource or partnersource:

Do you work for a Microsoft Partner or are you working as a freelance?