Skip to main content
Participant
March 2, 2023
Answered

Nested if function

  • March 2, 2023
  • 1 reply
  • 556 views

Hi,

is it possible to create an if statement where fieldA is populated with a number if fieldB is filled in with a specific number, but if fieldB is filled in with that specific number and fieldC is filled in with a specific word the result in fieldA changes? 

This topic has been closed for replies.
Correct answer try67

Sure, although you also need to specify what will be the value of the field in all other scenarios.

Use something like this:

 

var b = Number(this.getField("B").valueAsString);
var c = this.getField("C").valueAsString;

if (b==6) {
	if (c=="Apple") {
		event.value = "Something else";
	} else event.value = b;
} else event.value = "???";

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 2, 2023

Sure, although you also need to specify what will be the value of the field in all other scenarios.

Use something like this:

 

var b = Number(this.getField("B").valueAsString);
var c = this.getField("C").valueAsString;

if (b==6) {
	if (c=="Apple") {
		event.value = "Something else";
	} else event.value = b;
} else event.value = "???";
Participant
March 2, 2023

Thank you, it worked!