How to get Percentage value

Supriya25
Tera Guru

Hi,

Through Business rule i am getting right Percentage , but client wants onChange

find_real_file.png

Total Revenue of Project ( $ ) - field Integer type

Project Profitability ( $ ) - field Integer type

Formula : (U-R)/U

var projectrevenue = g_form.getValue('u_total_revenue_per_milestone'); //U//
var projectcost = g_form.getValue('u_project_profitability'); //R//
var percentage=(projectrevenue -projectcost )/projectrevenue 
 var percentagevalue = percentage * 100;
 alert('percentage :'+percentagevalue);
 g_form.setValue('u_gpm', percentagevalue.toFixed(2));

1 ACCEPTED SOLUTION

Try below.

var projectrevenue = g_form.getValue('u_total_revenue_per_milestone').replace(/,/g,'')); //U//
var projectcost = g_form.getValue('u_project_profitability').replace(/,/g,'')); //R//
var pr = parseFloat(projectrevenue);
var pc =parseFloat(projectcost);
alert(pr + "---" + pc);

var percentage = pr - pc;

alert(percentage);
var uu = percentage / pr;
alert(uu);
var percentagevalue = parseFloat(percentage * 100);
alert('percentage :' + percentagevalue);
g_form.setValue('u_gpm', percentagevalue.toFixed(2));

View solution in original post

18 REPLIES 18

Hi Mike,

find_real_file.png

Oh yes, Totally forgot that it can be only used in server side script.

so try

var projectrevenue = g_form.getValue('u_total_revenue_per_milestone'); //U//
var projectcost = g_form.getValue('u_project_profitability'); //R//
var pr = parseInt(projectrevenue);
var pc =parseInt(projectcost);
alert(pr + "---" + pc);

var percentage = pr - pc;

alert(percentage);
var uu = percentage / pr;
alert(uu);
var percentagevalue = parseFloat(percentage * 100);
alert('percentage :' + percentagevalue);
g_form.setValue('u_gpm', percentagevalue.toFixed(2));

mihirr
Tera Expert

Hello,

A solution for this, when we want to use an integer field for a calculation we don't need the comma's.

So add the attribute "format=none" to the dictionary entry of the respective integer fields. This will drop the comma allowing the calculation to work.

Let me know if it worked.

Regards,

Mihir Rathod.

My trial screenshot,

find_real_file.png