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.

Using "If" in script

Featured Replies

Hi

I am using an If function in a script where i wish the outcome based on two possible entries in a field. For example I wish an action to happen if the Status field in the Customer table equals M2 or TBR. I have tried the calculation Customers::Status ≠ "M2" xor "TBR" and a number of other possible variations. Can anyone let me know where I am going wrong.

Try this:

If [ Status = "M2" or Status = "TBR" ]

#do something

End If

Just saw the comment, "and other possible variations." Why don't you explain further. You may need to set a flag field that describes the state of the record, and use that in your If script statement.

Edited by Guest
added more

  • Author

Hi thanks that does work. The problem I am having is when I turn it around to being not equal to. When I change the formula from Customers::Status = "M2" or Customers::Status = "TBR" (Which works) to Customers::Status ≠ "M2" or Customers::Status ≠ "TBR" is does not perform as expected, ie performing the action when the status field is not M2 or TBR. The formula does work however it it is just one result eg. Customers::Status ≠ "M2"

  • Author

I have made this work by changing the code to the following:

(Customers::Status = "M2" or Customers::Status = "TBR") = False

That is not a valid calculation. Two not equals doesn't work because it may always be true.

What is the complete test?

I not sure what you are trying to do, but have you tried the Else If statment?

If ( Customers::Status = "M2" )

Do something

Else If (Customers::Status = "TBR")

Do something

Else If (Customers::Status = "X")

Do something else

(Customers::Status = "M2" or Customers::Status = "TBR") = False

That is not a valid calculation.

Of course it is. It's not only valid, but also correct. It's the same as:

not ( Customers::Status = "M2" or Customers::Status = "TBR" )

which could also be written as:

Customers::Status ≠ "M2" [color:red]and Customers::Status ≠ "TBR"

(Customers::Status = "M2" or Customers::Status = "TBR") = False

But isn't that asking: ( 1 ) = False or ( 0 ) = False

It would always fail. IIRC, false hasn't been boolean 0 since vs. 6; along with F & N & no. False is no longer not, no?

Edited by Guest

Let's not get confused here. Text values like "Y", "N", "T", "F", "True" and "False" are no longer evaluated as Boolean. But the reserved keywords True and False can be used in a calculation formula instead of 1 and 0.

Oh, right! Not sure why I saw "False" when Barbara said it wasn't valid; maybe she saw it same way I did. Without quotes, it is certainly valid! Thanks for the reminder, Michael.

Customers::Status ≠ "M2" and Customers::Status ≠ "TBR"

That is a construct I do use, although I prefer to write in positive case when possible. I'm not familiar with the use of False, my apologies, it just looked so wrong. It certainly doesn't read as well to me.

Anywho, I think that Lee's suggestion is probably the way to go if the tests are numerous. But since we don't have enough info, it's just guessing at this point.

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.