Matt65 - Friday, October 8, 2010 5:03 PM:
I need to be able to calculate a field based on other fields. For example, if I have a net weight and a packaging weight, I want my this: gross weight = net weight + packaging weight. How do I go about creating that new field. I am just getting my feet wet in Aras so I'll need step by step instructions on how to do this. Thanks.
Brian - Monday, October 11, 2010 6:46 AM:
HI Matt,
Not sure how wet your feet are yet.
Let's assume you have a form with three fields named: gross_weight, net_weight, packaging_weight. These are also the names of the properties in your item that are the data sources for the fields.
On each of the two fields that are part of your sum you want to put a Field Event called "SumOfWeights" which is called on the "onChange" event of both of the fields.
The Javascript code should be something like:
var netWeightFld = document.getElementsByName("net_Weight");
var packWeightFld = document.getElementsByName("packaging_weight);
var grossWeightFld = document.getElementsByName("gross_weight");
var netWeightVal = netWeightFld[0].value;
var packWeightVal = packWeightFld[0].value;
var grossWeightVal = parseFloat(netWeightVal) + parseFloat(packWeightVal);
grossWeightFld[0].value = grossWeightVal.toString();
return this;
Whenever one of the fields that makes up the sum is changed the sum will be re-calculated. Make the field visible but disabled and when you save the item the three field values will save to the data table.
Hope this helps,
Brian.
xueron564 - Sunday, August 14, 2011 8:53 PM:
888xuerong-3:
Fantomas - Friday, November 5, 2010 6:38 AM:
Yeah, you wrote the Javascript code for this, but isn't there an option we can click on directly on Aras to do this sum?
For example, we have two different fields in a base, and we create a third one and want it to equal ro the sum of the two previous ones... (just like Excel does actually)
I haven't downloaded Aras yet by the way. This was just a small question I wanted to ask out of curiosity...
Thanks