Hello.
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
Code:
RoutLine.RESET;
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;
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.
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)
Why do you create a SumTotal100 Function?
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.