Skip to main content
Participant
Mar 2, 2023 10:05 AM UTC
Answered

Nested if function

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Mar 2, 2023 10:15 AM UTC

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 = "???";

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Mar 2, 2023 10:15 AM UTC

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 = "???";
Translate
Participant
Mar 2, 2023 12:21 PM UTC

Thank you, it worked!

Translate