locked
CRM Quote.TotalTax Java Script RRS feed

  • Question

  • Hi Guys,

    Does anyone have any Java script to allow me to populate the CRM "quote.TotalTax" attribute?  I basiclly want CRM to calculate the VAT at 15%. So it'll need to be....  [0.15 * Totallineitemamount]

    I had the following onLoad code running [below] however the TotalTax attribute is just showing "NaN" as the value! What have I done wrong - something to do with the type of field???


    {
    crmForm.all.totaltax.value = (crmForm.all.new_currentvatrate.value)*(crmForm.all.totallineitemamount.value );
    }

    Thanks
    Wednesday, September 16, 2009 2:11 PM

Answers

  • Hi.

    Try to change your code to following:

    crmForm.all.totaltax.DataValue = (crmForm.all.new_currentvatrate.DataValue)*(crmForm.all.totallineitemamount.DataValue);
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Wednesday, September 16, 2009 2:30 PM
    Moderator
  • Hi.

    Are both of fields new_currentvatrate and totallineitemamount filled at the moment of form loading?

    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Wednesday, September 16, 2009 4:08 PM
    Moderator

All replies

  • Hi.

    Try to change your code to following:

    crmForm.all.totaltax.DataValue = (crmForm.all.new_currentvatrate.DataValue)*(crmForm.all.totallineitemamount.DataValue);
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Wednesday, September 16, 2009 2:30 PM
    Moderator
  • Hi,

    Thanks for the suggestion.

    Tried that but the Totaltax is just blank?? Could it be to do with the attribute data types or even, do I need additional code to go into the OnSave event of the form?

    Wednesday, September 16, 2009 3:14 PM
  • Hi.

    Are both of fields new_currentvatrate and totallineitemamount filled at the moment of form loading?

    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Wednesday, September 16, 2009 4:08 PM
    Moderator
  • Hi Andriy,

    Just re-checked everything and republished the Quote entity, restarted IIS - it's working now, so thank you.

    The only issue now is the Total Amount (totalamount) doesn't appear to be adding the Sub total (totallineitemamount) and the VAT (totaltax) together. From looking at the quote the Total amount field is only showing the Sub Total.

    Any ideas?

    Thank you :)

    Wednesday, September 16, 2009 5:24 PM
  • need to do it manually in the javascript as ur on load function executes only after populating all the existing fields if u do any changes to any value which is dependent on other values then u need to manually do the operations

    Thursday, September 17, 2009 12:43 PM
  • You may have to add a FireOnChange() function to the other fields.  Check out this article and see if it helps.  You might also need to set the field value to 0 (zero) in the FORM OnLoad event if the field does not contain a value when the form loads.  This means you have to first check for a null value in the Form OnLoad event and set the required fields to 0 if the value found = null
    Best Regards, Donna
    Thursday, September 17, 2009 3:08 PM