Hi everyone, I hope you are all well. Our Dynamics 365 CRM just updated to the new unified platform and now one of the scripts that used to run flawlessly for the last 5 years no longer works.
I have a simple cost calculator setup in our opportunity screens that calculates sell price or Gross profit margin based on a selection the user makes.
When you execute the script the error Value should be of type: boolean pops up as an error.
I didn't write the script, it was setup years ago and I have no idea what to do to fix this issue.
Below is a copy of the script that runs. Can anyone help? Much appreciated!
function CalculateRevenue(button,calculation,costprice,sellprice,gpmpercent) {
Xrm.Page.data.entity.save();
var recalculate = Xrm.Page.data.entity.attributes.get(button);
recalculate.setValue(0);
var cost = Xrm.Page.data.entity.attributes.get(costprice).getValue();
var calc = Xrm.Page.data.entity.attributes.get(calculation).getValue();
if (calc > 0) {
var revenue = Xrm.Page.data.entity.attributes.get(sellprice);
var gpm = Xrm.Page.data.entity.attributes.get(gpmpercent).getValue();
revenue.setValue(0);
if (gpm < 99.99) {
revenue.setValue(cost/(1-(gpm*.01)));
}
else {
alert ("*** to set GPM to 100% set COST to Kinetix to 0");
}
}
if (calc < 1) {
var gpm = Xrm.Page.data.entity.attributes.get(gpmpercent);
var revenue = Xrm.Page.data.entity.attributes.get(sellprice).getValue();
gpm.setValue(0);
if (cost > revenue) {
alert ("***ERROR COST to kinetix is greater than SELL PRICE");
}
else {
gpm.setValue(((revenue-cost)/revenue) *100);
}
}
}