Need a business rule script for currency fields

rani4
Mega Contributor

Hi All,

Need business rule script , three fields are currency fields.

 "Planned value to deliver" = Project "Allocated Cost" minus "Actual Cost with Resource Plan" = 100 - 0 = 100

1 ACCEPTED SOLUTION

Not applicable

Hi Rani,

Try using following Before BR :

(function executeRule(current, previous /*null when async*/) {

	var rate1 = parseFloat(current.u_field1);
	var currencyCode1 = current.u_field1.getCurrencyCode();
	
	var rate2 = parseFloat(current.u_field2);
	var currencyCode2 = current.u_field2.getCurrencyCode();
	
	
	var result = parseFloat(rate1-rate2);
	gs.addInfoMessage(result);
	
	current.setValue('u_field3',result);

View solution in original post

8 REPLIES 8

Not applicable

Replace my demo fields(field1,field2,field3 of type currency) with your fields of type currency.

rani4
Mega Contributor

Thank Ajay for your reply

but, i need after business rule because, the three fields are read only we auto populate the first two fields and then third fields must get subtract  and autopopulate

Shweta KHAJAPUR
Tera Guru

Hi Rani,

Try with below script in before BR,

(function executeRule(current, previous /*null when async*/) {

	
	var allocateCost =  parseFloat(current.u_allocated_cost);
	var actualCost =  parseFloat(current.u_actual_cost);
	var plannedValue = parseFloat(allocateCost - actualCost);
	current.setValue('u_planned_value',plannedValue );


})(current, previous);

Thank Ajay for your reply

but, i need after business rule because, the three fields are read only we auto populate the first two fields and then third fields must get subtract  and autopopulate