I do not understand why this will only work if both fields are populated. I would also like to know if I could assign a value to variable based on what fields are populated. This is what I have so far, any help / guidance would be greatly appreciated.
// Populates fieild based on whether Team or TeamA is populated. If Team is populated it will set the event.value to team and add values to a set of variable. If Team is Null and TeamB is populated it will add a different value to the variables;
var team = this.getField("Team");
var teama = this.getField("TeamA");
var teamz = this.getField("TeamZ");
event.value = "";
if(team.value==null&&teama!==null) { teamz.value=teama.value
}
if(teama.value==null&&team!==null) { teamz.value=team.value
}
if(teama.value!==null&&team!==null) { teamz.value=team.value
}
The value of an empty field is usually not null but an empty string. And yes, it can be done.
You should be using event.value, though, not getField, to set the value of the field where this calculation is located ("TeamZ"), in this case.