Howdi,
I have a web resource set up that is meant to total 10 fields and check it against another, if they do not match a warning appears. I have this working on CRM 2011 but cannot get it to work in CRM 2013. Field names have changed and I have triple checked and got someone else to check they are correct in the code.
Code is as follows:
function calculate(ExecutionObj) {
var val1 = Xrm.Page.getAttribute(new_fld1).getValue();
var val2 = Xrm.Page.getAttribute(new_fld2).getValue();
var val3 = Xrm.Page.getAttribute(new_fld3).getValue();
var val4 = Xrm.Page.getAttribute(new_fld4).getValue();
var val5 = Xrm.Page.getAttribute(new_fld5).getValue();
var val6 = Xrm.Page.getAttribute(new_fld6).getValue();
var val7 = Xrm.Page.getAttribute(new_fld7).getValue();
var val8 = Xrm.Page.getAttribute(new_fld8).getValue();
var val9 = Xrm.Page.getAttribute(new_ld9).getValue();
var val10 = Xrm.Page.getAttribute(new_fld10).getValue();
var val11 = Xrm.Page.getAttribute(new_Hosting).getValue();
var total = 0;
if (val1 != undefined && val1) total += val1;
if (val2 != undefined && val2) total += val2;
if (val3 != undefined && val3) total += val3;
if (val4 != undefined && val4) total += val4;
if (val5 != undefined && val5) total += val5;
if (val6 != undefined && val6) total += val6;
if (val7 != undefined && val7) total += val7;
if (val8 != undefined && val8) total += val8;
if (val9 != undefined && val9) total += val9;
if (val10 != undefined && val10) total += val10;
if (val11 != undefined && val11) total += val11;
var orderTotal = Xrm.Page.getAttribute(new_total).getValue();
if (orderTotal != total) {
alert('Forecast does not equal Total Order, please amend');
ExecutionObj.getEventArgs().preventDefault();
}
}
I have it set to execute 'onsave' along with a script that stops the auto save on modify/30secs (which works) but when I save I get an error:
Field: CRM Form
Event: onsave
Error: new_fld1 is undefined
I have tried field names with proper capitalisation as in the schema name and all lower case. I have tried adding ' ' around the Schema names in the code too.
So basically is my code correct? Or can you offer any other guidance.
Thanks
*This post is locked for comments