I'm new to JavaScript, working on a couple client scripts in CRM. The issue I am having is with a conditional statement where I am trying to validate that a field is neither null nor zero before doing some calcs. The if statement is:
if (propBldSF != null && propBldSF != 0) {
log("not null")
}
This works once when the page loads (Page Event/onChange) and then it will work again if I make a change to the Building_SF field that the propBldSF variable pulls the data from, then any portion of the script fails to run until I restart the test run.
More details of the active part of the script are below, I'm trying to get past this glitch before finishing it up and writing the actual calculations.
Thanks in advance. Richard
**************************************************
var propVerfied = ZDK.Page.getField("Verified").getValue();
var propBldSF = ZDK.Page.getField("Building_SF").getValue();
var propTotAcres = ZDK.Page.getField("Total_Acres").getValue();
var propImpAcres = ZDK.Page.getField("Improved_Acres").getValue();
if (propTotAcres != null) {
var propSF = Math.round(propTotAcres * 43560);
var fieldTotLndSF = ZDK.Page.getField("Total_Land_SF").setValue(propSF);
}
else {
var propSF = ("0");
var fieldTotLndSF = ZDK.Page.getField("Total_Land_SF").setValue(SF);
}
if (propBldSF != null && propBldSF != 0) {
log("not null")
}
else {
log("null or zero")
}
if (propVerfied == "Verified") {
log(propVerfied)
var fieldAPN = ZDK.Page.getField("APN").setValue("Verified");
}
else {
log(propVerfied)
var fieldAPN = ZDK.Page.getField("APN").setValue("Not Verified");
}