Skip to main content
Inspiring
March 7, 2017
Question

Need to fill a field and assign variable values based on whether two other fields are null or populated

  • March 7, 2017
  • 1 reply
  • 252 views

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
}

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
March 7, 2017

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.