User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:adminmanual:businessmappings:field_dependency [2019/03/06 15:12]
gmoshi
en:adminmanual:businessmappings:field_dependency [2020/02/06 01:04] (current)
joebordes [Examples]
Line 522: Line 522:
 </​code>​ </​code>​
  
 +<WRAP center round box 80%>
 +Change tax percentage when picklist with tax type changes
 +</​WRAP>​
 +
 +<code XML>
 +<map>
 +  <​originmodule> ​ <​originname>​Invoice</​originname>​ </​originmodule>​
 +<​dependencies>​
 +<​dependency>​
 +    <​field>​cf_879</​field>​
 +    <​actions>​
 +        <​function>​
 +            <​field>​cf_879</​field>​
 +            <​name>​changeTaxDetails</​name>​
 +            <​parameters>​
 +            </​parameters>​
 +        </​function>​
 +    </​actions>​
 +</​dependency>​
 +</​dependencies>​
 +</​map>​
 +</​code>​
 +
 + <code JS>
 +function changeTaxDetails(change_field,​ action_field,​ new_value, old_value) {
 +    if (action_field == '​cf_879'​) {
 +        if (new_value != '​Guardias'​) {
 +            document.getElementsByName('​tax2_group_percentage'​)[0].value = 0.00;
 +        } else {
 +            document.getElementsByName('​tax2_group_percentage'​)[0].value = -6.00;
 +        }
 +        calcTotal();​
 +    }
 +}
 +</​code>​
 +
 +you can load the JS from a file in the footer with:
 +
 +<​code>​BusinessActions::​addLink(getTabid("​Invoice"​),​ '​FOOTERSCRIPT',​ '​corebosjshookinvoice',​ '​modules/​Invoice/​corebosjshookinvoice.js',​ '',​ 0, null, false);</​code>​