locked
Customize opportunity pricing RRS feed

  • Question

  • Hey All,

    This is my first question here :) and so i am new to CRM development. 

    Here is the deal , the price list that the customer has got same products on different units , some of which is a discount to list price. ie.

    the list price is 1000 for an apple and the price list for a unpacked apple is 1000 * 0.9 (90%) . 

    The system calculates the price  properly. What I would like to show to the user is what % was used from list price to this price ..

    So far , i have added a field , then I am not sure where to continue from here ? 

    tx,

    Gabor

    Monday, February 11, 2013 5:57 PM

Answers

  • Use this script to update the discount percent "on save" of the form:

    function OnSave() {

    var ext = Xrm.Page.getAttribute("extendedamount").getValue();

    var disc = Xrm.Page.getAttribute("discountamount").getValue();

    var DiscPerc = disc\ext;

    Xrm.Page.getAttribute("new_discountpercent").setValue(DiscPerc);

    }

    You may need to save the form once, and then save and close to take effect in some cases such as volume discount fields. Because it is populated after save and load of the form.


    If the answer helped you, remember to mark it as answer.

    Monday, February 11, 2013 6:59 PM
    Moderator

All replies

  • Use this script to update the discount percent "on save" of the form:

    function OnSave() {

    var ext = Xrm.Page.getAttribute("extendedamount").getValue();

    var disc = Xrm.Page.getAttribute("discountamount").getValue();

    var DiscPerc = disc\ext;

    Xrm.Page.getAttribute("new_discountpercent").setValue(DiscPerc);

    }

    You may need to save the form once, and then save and close to take effect in some cases such as volume discount fields. Because it is populated after save and load of the form.


    If the answer helped you, remember to mark it as answer.

    Monday, February 11, 2013 6:59 PM
    Moderator
  • Hi Faludi,

    In order to do this, you need to create a JavaScript Web Resource. In this web resource you will define the function to be called when saving a form.

    Then you should open your form on edit mode and update it's events so that it call the new function on the OnSave as Payman suggested.

    Don't forget to publish your new customizations.

    You can also use the OnChange event on a field to update the value of DiscountPercent.

    • Proposed as answer by Zouma Thursday, February 14, 2013 6:41 PM
    Monday, February 11, 2013 7:19 PM
  • If the answer helped you please mark it as answer. Thanks.

    Tuesday, February 12, 2013 8:09 PM
    Moderator