Calculated V Function Field

Ian Elrick1
Kilo Expert

Hi

I have created a table with 3 Decimal columns. I want to have a field that just sums the 3 columns together and displays that total in the default view for the record. Nothing complex in that I would have thought. 

However I cant get it to work using either a Calculated Field or a Function Field.  There seems to be a real lack of documentation re how function fields work with examples. 

Anyone advise what is the best way to do this and if either calc field or function field, some sample code to achieve 

My calculated field code was:

(function calculatedFieldValue(current) {
 var total2=ParseFloat(current.mon_2)+ParseFloat(current.tues_2)+ParseFloat(current.wed_2);
 return total2;

 //return "42.0";  // this was to see if basic retun to calc field was working. It was not.
})(current);

 

Thanks in advance

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

did you try below

(function calculatedFieldValue(current) {
 var total2=current.mon_2 + current.tues_2 + current.wed_2;
 return total2;

 //return "42.0";  // this was to see if basic retun to calc field was working. It was not.
})(current);

View solution in original post

4 REPLIES 4

Mike Patel
Tera Sage

did you try below

(function calculatedFieldValue(current) {
 var total2=current.mon_2 + current.tues_2 + current.wed_2;
 return total2;

 //return "42.0";  // this was to see if basic retun to calc field was working. It was not.
})(current);

This worked thanks. Not sure what the issue was before but is resolved now.

Please mark answer correct so it gets removed from unanswered list.

jbasa
Tera Contributor

This was a couple of years ago I know however wanted to ask.  can I add to the script to see if the toal matches one of 5 numbers.  If so, not changes, if not, pop-up an alert?

 

What i have is are lease rates that can be split across 10 department numbers.  Adding it up works, just want to create some sor tof validation if the total does not equal number.  For the example we product 1 which can only be say 75 or 100 and Product 2 which can only add up to 100 150.