What am I missing - Combining scripts

I am trying to get a script to work with 2 data fields.
“CURR PMT” not equal to “$0.00”
“PROP_Collateral ST CD” equals “CT”

From snippet I am always getting an error, have tried numerous times to correct (only to make it worse).

Sure a second set of eyes can resolve. Thank you in advance.

Hi NMjoy,

You needed to use square brackets around your field names. If you type slowly Connect will suggest what code to type next. (a type of intellisense) If you had done so you would see that Connect will put them in square brackets due to the field names having spaces.

So if my field was called myFieldName, Connect code would look like this without square brackets.

record.fields.myFieldName;

The other error was the missing closing curly bracket to end your if statement. If you hover your mouse over the red circled X indicating an error on line 6, Connect would of informed you of it been missing.

My use of !== over != is just out of habit. !== compares value and type of field.

if (record.fields["CURR PM"] !== "$0.00" && record.fields["PROP_Collateral ST CD"] == "CT") {
	results.show();
} else {
	results.attr("data-conditional","");
	results.hide();
}

You can take a look at this site for some JavaScript info and tutorials. I had to learn it too when upgrading to Connect.

Regards,
S

1 Like

Sharne,

Thank you for reply, and pointing out what I could have done to find the issue.

  • square brackets due to the field names having spaces vs without square brackets

  • slowly Connect will suggest what code to type next

Hopefully in time :):smile: I’ll get this java script down pat.

Have a wonderful day,
Nancy