Expand my Community achievements bar.

SOLVED

Check for null field

Avatar

Level 7

I have a FormCalc script that checks to see if TextField1 == TextField 2 and if it does then set a value of 1, if they're not equal, then 0.

However, the form is setting the value to 1 even though there is no entry in either field. I'm thinking I need to include an expression in the formula that says if the fields are null don't set a value. I'm not sure how to do this. Can someone help?

Thanks,

MDawn

1 Accepted Solution

Avatar

Correct answer by
Level 10

replace "!=" with "ne" in your code..

!= is a javascript notation.

ne is a FormCalc notation..

Thanks

Srini

View solution in original post

9 Replies

Avatar

Level 7

if

(form1.page16c.Table1.Row1.posPrice10 == form1.page16c.Table1.Row1.shelfPrice10) then

1

else

0

endif

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Former Community Member

You can check to see if the field is Not null and it equals the other field. Something like this:

if ((form1.page16c.Table1.Row1.posPrice10 == form1.page16c.Table1.Row1.shelfPrice10) & (form1.page16c.Table1.Row1.posPrice10 != null)) then

     1

else

     0

endif

This will mean that the field form1.page16c.Table1.Row1.posPrice10 must not be null and equal to the other field before a 1 will be placed in the field. Otherwise a 0 will be placed in the field.

Paul

Avatar

Level 7

Thank you. I'll try this.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I'm getting a "syntax error near token ! on line..."

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Correct answer by
Level 10

replace "!=" with "ne" in your code..

!= is a javascript notation.

ne is a FormCalc notation..

Thanks

Srini

Avatar

Level 7

Got it. Thanks.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

Now it doesn't like the &

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I figured it out. Thanks.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065