Skip to main content
Known Participant
Oct 18, 2019 3:24 PM UTC
Answered

Another if/else query - help needed again please *solved*

I'm missing something again as this isn't working either 😞

The first part - if "vat rate.10" says Exempt then "vat value.10" will show 0 - works great, but I can't get the next bit to work. If "vat rate.10" contains a value (any percentage), then "vat value.10" should show "aVATRate.10 x "net value.10"

 

 

if (this.getField("vat rate.10").value == "Exempt") {
event.value = 0;
}
else {"aVATRate.10"*"net value.10";
}

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Oct 20, 2019 9:18 AM UTC

Use this code:

 

if (this.getField("vat rate.10").value == "Exempt") {
	event.value = 0;
} else {
	event.value = Number(this.getField("aVATRate.10").valueAsString) * Number(this.getField("net value.10").valueAsString);
}

7 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Oct 20, 2019 9:18 AM UTC

Use this code:

 

if (this.getField("vat rate.10").value == "Exempt") {
	event.value = 0;
} else {
	event.value = Number(this.getField("aVATRate.10").valueAsString) * Number(this.getField("net value.10").valueAsString);
}
Translate
jlehaneAuthor
Known Participant
Oct 20, 2019 12:53 PM UTC

Perfect!!!! Thank you Try 67, much appreicated 🙂

Translate
Bernd Alheit
Community Expert
Community Expert
Oct 18, 2019 3:37 PM UTC

To access field values you must use:

this.getField(" field name ").value

Translate
jlehaneAuthor
Known Participant
Oct 18, 2019 3:40 PM UTC

So where would that bit go in my poor attempt in the original question?

Translate
Bernd Alheit
Community Expert
Community Expert
Oct 18, 2019 3:44 PM UTC