If I compare 2 number fields in an @If statement, it should return boolean right? I’m trying to compare 2 simple decimal numbers (all numbers greater than 8 get a warning message) and it simply does not work, here’s an excerpt:
@If(InsiderHours > MaxHours;FIELD HourDec := @Text(@Prompt([YesNo];“Verify Hours”;“You have selected greater than 8 hours for this, is this correct?”));FIELD HourDec := “1”);
Both InsiderHours and MaxHours are NUMBER style fields on this form, this is all in an action button that prompts for input. I’ve tested the flow and the numbers should be available for comparison, I even make the fields on the form readable so I can clearly see that the data is there, but the function just doesn’t seem to work.
Any help is greatly appreciated, but please keep this in formula lang, I really don’t have the time to write a full lotusscript/javascript version of my code.
Subject: Numeric comparison (“>”) in an @If
Have you tried the following, which seems more likely to work? Also, have you made sure the value of InserHours and MaxHours are both numeric?
FIELD HourDec := @If(InsiderHours > MaxHours;@Text(@Prompt([YesNo];“Verify Hours”;“You have selected greater than 8 hours for this, is this correct?”)); “1”);
Subject: RE: Numeric comparison (“>”) in an @If
I agree with Ben and his sample is how I generally write my forumlas.
I believe the @SetField works inside @If statements, but I’ve never liked using it for some reason. The syntax would be similar to:
FIELD HourDec := HourDec;
@If(InsiderHours > MaxHours;@Setfield(HourDec,value);@Setfield(HourDec;“1”));
To get back to your original question, I’m not sure I’m comfortable with you assigning the output of the @Prompt through the @Text function. @Prompt returns boolean .true. or .false., so does that get translated into a “0” or “1” if you put it through the @Text function?
How about something like:
hoursOK := @If(InsiderHours > MaxHours;@Prompt([YesNo];“Verify Hours”;“You have selected greater than 8 hours for this, is this correct?”)); @True);
FIELD HourDec := @If(hoursOK;“1”;“0”)
Subject: Numeric comparison (“>”) in an @If
What did the help have to say?