- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 04:53 AM
Hi,
Through Business rule i am getting right Percentage , but client wants onChange
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));
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 05:52 AM
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));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 07:13 AM
Hi Jaspal,
your script is working fine,Thanks for script.
can you tell me .replace(/,/g,'')); what will do here.?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 07:33 AM
So, when you used parseFloat() it ignored the text after ',' (comma).
Using .replace(/,/g,'')); will ensure that 201,450 is considered as 201450.
In short it replaces , (comma) with nothing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 07:47 AM
do we have this .replace(/,/g,'')); at javascript side

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 07:56 AM
.replace() yes it is. Did you try it with code above? If not try & check for difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 09:24 AM
Sorry for delay reply.
can you help me what is the meaning of (/,/g,'')