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.

IF Script step

Featured Replies

I'm still very new to FM and scripting so please bare with me. What I would like to accomplish is this: a simple IF step where: if the records found = more than 1 it takes me to a certain layout and if the records = 1 it takes me to another layout.

Could someone please show me an example of this.

Tks

Shaun

Hi Shaun,

Since you are using vs. 6 -

Set Error Capture [ On ]

Allow User Abort [ Off ]

Enter Find Mode [ [color:gray]* ]

[color:gray](see note below on how to handle asterisks or what goes here)

Perform Find [ [color:gray]*]

If [ not Status ( CurrentFoundCount ) ]

Show Message [ “No records found “ ]

Halt Script

End If

If [ Status ( CurrentFoundCount ) = 1 ]

Go To Layout [ form detail layout ]

Else

Go To Layout [ list layout ]

End If

How to handle the portions with asterisk:

[color:gray]* ... you haven't said how the find needs to happen; whether it's a stored find or User controlled so I cannot tell you whether to pause your script or manually perform it and then REPLACE within your script. Versions less than 7 were a PIB because of the replace/restore issues.

If you need help working through this further, just let us know how the find needs to happen; whether User will input criteria or whether you wish to set the fields yourself or a combination of both.

LaRetta :wink2:

  • Author

Hi Laretta

Thanks so much for your help.

I am programming this script in fm 8 Pro, so the scripting may be a bit different as I haven't had too much luck getting it right. It will be user controlled, as they will be inputing their client reference number.

Here is a screenshot of my scipting:

Thanks again

Don't use pause/resume script [indefinitely]. FM will pause your script when you put the 'pause' in the Enter Find Mode [] portion. Change your script back to what I had as:

Go to Layout [ search ; ShipTo ]

Set Error Capture [ On ]

Allow User Abort [ Off ]

Enter Find Mode [ [color:red]pause ]

Perform Find [ ]

If [ not Get( FoundCount ) ]

Show Message [ "OK" ; "No records found"]

Show All Records

Go to Layout [ original layout ]

Halt Script

End If

If [ Get ( FoundCount ) = 1 ]

Go To Layout [ Ship2 ; Ship2 ]

Else

Go To Layout [ List shipments ; ShipTo]

End If

I think that should do it for you. Let us know if not. :wink2:

UPDATE: Oh, I changed it from Status ( CurrentFoundCount ) to Get ( FoundCount ). Your profile and your first post BOTH show that you wanted this script for vs. 6 so you might change your profile if your future needs will be for vs. 8. It will make a BIG difference in any responses you receive.

LaRetta

Edited by Guest
Added update

  • Author

Thanks for your help, I eventually got it right.

cheers

Shaun

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.