OnSave Javascript for CRM 2011 quote product -


i have script on quote product want update tax value when saving form. but, did update tax according previous values of fields. script as:

function tax () {    var val0 = xrm.page.getattribute("baseamount").getvalue();    var val1 = xrm.page.getattribute("manualdiscountamount").getvalue();    val2 = val0 - val1;    val2 = val2 * 0.05;    xrm.page.getattribute("tax").setvalue(val2); } 

for example, if base amount 10 , manual discount 1 on create of quote product, tax updates 0. if after save, change base amount 20 , manual discount 1, tax updated 0.45! mean that, calculates tax based on previous values of fields!

you facing issue because baseamount value before crm updates it.

baseamout calculated after form saved, need calculate value hands simplified example:

function tax () {    var priceperunit = xrm.page.getattribute("priceperunit").getvalue();    var quantity = xrm.page.getattribute("quantity").getvalue();    var val0 = priceperunit * quantity;    var val1 = xrm.page.getattribute("manualdiscountamount").getvalue();    val2 = val0 - val1;    val2 = val2 * 0.05;    xrm.page.getattribute("tax").setvalue(val2); } 

pay attention there field volume discount , product can write-in.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -