Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

IF Script step


This topic is 6151 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

This topic is 6151 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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