calculating fields

This question has suggested answer(s)

I have searched through the forums and found a few posts regarding calculating fields, I have tried these and cannot seem to make them work for me!

I have 6 fields which I need to add up and the total displayed in the 7th field. Should this work:


oppo_c_sostotal
.value
=oppo_c_strengthofsalecollabora+oppo_c_strengthofsalecrta+oppo_c_strengthofsalepower+oppo_c_strengthofsalepain+oppo_c_strengthofsalevision+oppo_c_strengthofsalevalue

 It does not seem to work for me....is there something obvious i am doing wrong??

 

Thanks

 

 

All Replies
  • it might be easier using a derived field and doing the calculation in a view or updating the field via an escalation rule or a table script

    community.sagecrm.com/.../adding-derived-fields-in-views-into-meta-data.aspx

  • did you miss out the character ";" at the end of the statement ? was it an expected error or something else?

     

    Kannan Srinivasan

  • Thanks i am going to look into this

  • i have tried it with and without its still not working. Thanks

  • i found another method of doing it however it only works for adding up two fields! if i use

    oppo_sostotal.value=(parseFloat(oppo_sospain.value)+parseFloat(oppo_sospower.value)).toFixed(2)

    this adds those two fields up into the thrid. i have tried adding more fields to this code but it doesnt work so not sure.  i.e

    oppo_sostotal.value=(parseFloat(oppo_soscollaboration.value)+parseFloat(oppo_soscrta.value)+parseFloat(oppo_sosvalue.value)+parseFloat(oppo_sosvision.value)+parseFloat(oppo_sospain.value)+parseFloat(oppo_sospowervalue)).toFixed(2)

  • Hello Jen,

    Take the fields you need to calculate and place them into variables.

    eg:  

    var myvar1 = oppo_soscollaboration.value;

    var myvar3 = oppo_sospower.value;

    var myvar4 = oppo_soscrta.value;

    var myvar5 = oppo_sosvalue.value;

    var myvar6 = oppo_sosvision.value;

    var myvar7 = oppo_sospain.value;

    Next, put your calculation into a variable:

    var myvarsosTotal = (parseFloat(myvar1) + parseFloat(myvar4) + parseFloat(myvar5) + parseFloat(myvar6) + parseFloat(myvar7) + parseFloat(myvar3));

    set your field to show the calculation result and fix it to 2 decimal.

    oppo_sostotal.value = myvarsosTotal.toFixed(2);

    Let me know if this helps Jen.

    Regards,

    Penny

  • Thanks everyone! I have finally managed to get it to work using the following:

    var oppo_soscollaboration = crm.fields('oppo_soscollaboration').value();

    var oppo_soscrta = crm.fields('oppo_soscrta').value();

    var oppo_sosvalue = crm.fields('oppo_sosvalue').value();

    var oppo_sosvision = crm.fields('oppo_sosvision').value();

    var oppo_sospain = crm.fields('oppo_sospain').value();

    var oppo_sospower = crm.fields('oppo_sospower').value();

    var thetotal = parseFloat(oppo_soscollaboration) + parseFloat(oppo_soscrta) + parseFloat(oppo_sosvalue) + parseFloat(oppo_sosvision) + parseFloat(oppo_sospain) + parseFloat(oppo_sospower);

    crm.fields('oppo_sostotal').value(thetotal);