Skip to main content
Participating Frequently
March 25, 2023
Answered

Javascript Nested If punctuation

  • March 25, 2023
  • 2 replies
  • 843 views

I have 3 textboxes(tb) ("MandatoryTotalLodge01", "L1Lodge01MajorTotal" and "L1Lodge01BasicTotal")with calculated sums.If a condition in each field meets its criteria, a fourth textbox(target"CSComplete01") shows 1 message("Cornerstone Complete"), if ALL do not meet, it shows another ("Still Working"). The following is what I have in the the custom calculation of the target tb. I strongly feel its puncuation.

Any helpers?

 

if (this.getField(“MandatoryTotalLodge01”).value>= 1) && if(this.getField(“L1Lodge01MajorTotal”)>= 1)&& if(this.getField(“L1Lodge01BasicTotal”).value>= 1 );
{
event.value=this.getField("CSComplete01").value = "Cornerstone Complete";
}

This topic has been closed for replies.
Correct answer Nesa Nurani

You got that error because you didn't use correct quotes.

MandatoryTotalLodge01

"Cornerstone Complete"

The green ones are correct, but you also have other errors in your script.

Try to use this as custom calculation script of "CSComplete01" field:

var f1 = Number(this.getField("MandatoryTotalLodge01").valueAsString);
var f2 = Number(this.getField("L1Lodge01MajorTotal").valueAsString);
var f3 = Number(this.getField("L1Lodge01BasicTotal").valueAsString);

if(f1&&f2&&f3){
 if(f1>=1 && f2>=1 && f3>=1)
 event.value = "Cornerstone Complete";
 else
 event.value = "Still Working";}
else
event.value = "";

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
March 25, 2023

You got that error because you didn't use correct quotes.

MandatoryTotalLodge01

"Cornerstone Complete"

The green ones are correct, but you also have other errors in your script.

Try to use this as custom calculation script of "CSComplete01" field:

var f1 = Number(this.getField("MandatoryTotalLodge01").valueAsString);
var f2 = Number(this.getField("L1Lodge01MajorTotal").valueAsString);
var f3 = Number(this.getField("L1Lodge01BasicTotal").valueAsString);

if(f1&&f2&&f3){
 if(f1>=1 && f2>=1 && f3>=1)
 event.value = "Cornerstone Complete";
 else
 event.value = "Still Working";}
else
event.value = "";
Participating Frequently
March 28, 2023

Thank you VERY VERY much Nesa!! This got me out of a big jam.

Participating Frequently
March 25, 2023

I inserted a ".value" after my "if(this.getField(“L1Lodge01MajorTotal”)>= 1)" 

The error reads:

"Syntax Error: illegal character

1: at line 2