Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

I went wrong somewhere with My IF

Featured Replies

I'm trying to use the IF function to trigger one of two scripts. Currently, I have:

IF [isEmpty(Field 1)]

Perform Script [script 2]

ELSE

Perform Script [script 3]

End If

Scripts 2 and 3 work fine when I trigger them independent of the IF function, so I know that it's a simple case of my IF script not working. Basically, I want it to look at Field 1, and if that is Empty, trigger script 2. If field 1 is not empty, it should trigger script 3. Help, please!

Todd

Is there by chance any spaces or carriage returns in Field 1? If so, it isn't empty. For text fields, I would use IsEmpty( Substitute( Substitute( Field 1, "

  • Author

Outside of the field label, it is definitely empty. Does the name of the field affect this?

The label has no effect on the contents of the field.

In what mode are you running your test?

Hi Todd,

Have you tried your IF with another field? or with the Trim function?

BTW is your test field a text field?? does it have a default value set-up

in field defenitions?

You are certain your field is empty because script-3

is always the one that runs??

Todd, what is the behavior you are seeing?

  • Author

To sum up all of the questions:

Behavior: The IF script appears to check the field, but it never triggers the 2nd or 3rd script.

Mode: In Layout Mode or Browse Mode, same thing occurs

I tried flipping the IF script, in that I tried to use the IfValid function to trigger (and flip-flopped the scripts being triggered), but that didn't work either. I know the field is empty because I use the Clear function to clear it shortly before this script runs. It is a number field, by the way - perhaps that has some bearing on the matter?

I'm not familiar with the Trim function - what is that? I'll check the field definitions - maybe I inadvertently added something I shouldn't have.

Thanks

Aha. Don't use Clear() unless the field is on the current layout. It won't work. It's safer to always use SetField[field, ""] or, in the case of dates, SetField[field, TextToDate("")].

I know the field is empty because I use the Clear function to clear it shortly before this script runs.

Wether you use Clear or SetField....Why run an If script then B)tongue.gif

In that case, only script 2 would ever run. Hmm.

Hmmm- sounds like we need more info.

considering it is a number field, try:

IF [field1>0

Perform Script [script 3]

ELSE

Perform Script [script 2]

End If

if that doesnt work, try:

IF [field1>0

show message "Field1 is > 0!"

ELSE

show message "Field1 is not > 0!"

End If

if you get no results with the first one and a dialog box with the second, your problems lie in your scripts 2 and 3. If you get no dialog box with the second, something very odd it happening (are you sure field1 exists? are you sure you are triggering the correct script?)

Also- what are scripts 2 and 3 doing? try putting pauses at the beginning of scripts 2 and 3. If your scripts 2 and 3 are taking you to a layout in a different file, it may be thaat everything is working fine, but just returning to first file to finish the first script.

-Raz

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.