locked
How to Multiply Decimal and Currency Fields? RRS feed

  • Question

  • Hi,

    I want to multiply a decimal point field with currency field and want the result to get displayed in currency field. It will be helpful if you let me know how i can do that.

    Decimalpoint field * Currency field= Currency Field

    Thanks in advance

    Venkat


    • Edited by Venkat1986 Wednesday, September 5, 2012 12:34 AM
    Tuesday, September 4, 2012 11:58 PM

Answers

  • I found the answer.

    function calcTotal() {
    var decimal1= Xrm.Page.getAttribute("new_decimalfield1").getValue();
    var currency1 = Xrm.Page.getAttribute("new_currencyfield1").getValue();
    Xrm.Page.getAttribute("new_currencyfield2").
    setValue(decimal1* currency1);
    }
    • Marked as answer by Venkat1986 Wednesday, September 5, 2012 1:32 AM
    Wednesday, September 5, 2012 1:32 AM

All replies

  • currency or money fields internally store the value as decimal.

    Read the money property and use the .value property to get the decimal value of the field. You can then perform the calculations and assign the result to the .value property of the other money property that holds the result.

    HTH 

    Sam 


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    • Proposed as answer by Sam - Inogic Wednesday, September 5, 2012 12:30 AM
    Wednesday, September 5, 2012 12:30 AM
  • Hi Sam,

    Thanks for your reply. Can you please provide me sample code? I am not good with creating javascripts :(

    Venkat

    Wednesday, September 5, 2012 12:32 AM
  • I found the answer.

    function calcTotal() {
    var decimal1= Xrm.Page.getAttribute("new_decimalfield1").getValue();
    var currency1 = Xrm.Page.getAttribute("new_currencyfield1").getValue();
    Xrm.Page.getAttribute("new_currencyfield2").
    setValue(decimal1* currency1);
    }
    • Marked as answer by Venkat1986 Wednesday, September 5, 2012 1:32 AM
    Wednesday, September 5, 2012 1:32 AM