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.

Script not working correctly

Featured Replies

I have the following script setup and I cannot not get it to multiply when it is needed.

If (rate_code = "2")

Set Field Commission, Case(Price <= 400, "50", Price > 400 and Price <= 1000, "100", "150")

Else

If (rate_code = "3")

Set Field Commission, Case (Price < 200, " Price * .50",

Price >= 200 and Price < 1000, "100",

Price >= 1000 and Price <= 2000, " Price * .10",

Hi Dobbers,

Why Script it, you can do this with a calculation and two fields.

Commission number result =

Case(Price < 200, 50, Price <= 1000, 100, Price > 1000 , 150)

HTH

Lee

smile.gif

Hi Dobbers smile.gif

Your fields weren't enclosed in "" as they normally would display but your 'results' were ("100"), so I'm unsure ... but I think you may be typing "" in the Calculation Setup box? If your Price and Commission fields are number (and I assume they are), then FM is interpreting your "Price * .50" as text. "" would still work when Setting a number because FM will place text in a num field, but you can't use 'text' in a num field calculation crazy.gif

If [ Rate_Code = 2 ]

Set Field [ Commission, Case(Price <= 400, 50, Price <= 1000,

100, 150) ]

Else

Set Field [ Commission, Case(Price < 200, Price * .50, Price

<= 1000, 100, Price <= 2000, Price * .10, 200)]

End If

I noticed an inconsistency in your use of <= 1000 between Rate_Code 2 and 3 but your result (100) was the same. Was there an error in your original post or did you want that? IF so, you'll need to correct my Rate_Code 3 <= 1000 to <= 999.

You don't need to list the Rate_Code = 3 at the start of your Else statement because all remaining records (that aren't Rate_Code 2) will be Rate_Code 3 (they are the Else result). So there is no reason to require FM to use processor cycles to check the Rate_Code field at this late point in the script step. I think it's a bit simpler. So lose the "", correct the script and it should work fine.

I don't question why you are using a script. Only you know your solution and I assume you have reasons for scripting this data. I hope this solved your problem.

LaRetta

The answer I submitted was based on your last sentence of your post. However, after reading the post again, I see you had a second break point. Here is an ammended calculation that will do both.

Case(

rate_code = 2 and Price <= 400, 50,

rate_code = 2 and Price <= 1000, 100,

rate_code = 2 and Price > 1000, 150,

rate_code = 3 and Price < 200, 50,

rate_code = 3 and Price <= 1000, 100,

rate_code = 3 and Price > 1000, 150

)

HTH

Lee

smile.gif

  • Author

Thanks Lee, I think that is the answer I was looking for. I appreciate your feed back.

Robbydobbs

  • 1 month later...
  • Newbies

When printing,FM doesn't print to the default printer. How can I correct this problem? Also, Change Order: When printing, it defaults to Records Being Browsed instead of Current Record. How do I fix this problem?

That is in your print settings. You state whether or not you want the file to records being browsed or the current record. Is this print setting in your script? Make sure when you tell it to do this print command in your script that you have the correct printed selected at the time the script is written with the right settings.

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.