Jump to content
Server Maintenance This Week. ×

Search problem in FMP 4.1


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

Recommended Posts

Am currently producing an on-line searchable database using FMPro 4.1v2 and using FMP to serve the whole site. The server is a Mac (BW G3 350 runing OS 8.6).

Users are able to search for a list of records by entering any one or more of three parameters. A fourth parameter is permanently set by being a hidden input on the search page.

However if a search is made without putting in any user parameters the search returns all records which match the hidden parameter.

Although I understand why this is it means users get a list of about 800 records when by using one or more of the user parameters in addition the number of records returned will be no more than 30 or so.

What I want to do is produce an error to return an error page if none of the user parameters are entered.

Despite racking my brains and trying numerous ideas I have not yet come up with a solution.

Is such a situation possible using CDML or a script?

Link to comment
Share on other sites

You could test for Status(CurrentError) = 400 before continuing and setting the extra parameter.

Set Error Capture [On]

Enter Find Mode [Pause]

Perform Find [ ]

If [status(CurrentError) = 400]

[color:"white"]__Enter Find Mode [ ]

[color:"white"]__Show Message ["No criteria was entered."]

[color:"white"]__Exit Script

End If

Modify Last Find

Set Field [fieldA, "extra parameter"]

Perform Find [ ]

If [status(CurrentFoundCount) = 0]

[color:"white"]__Enter Find Mode [ ]

[color:"white"]__Show Message ["No records were found."]

[color:"white"]__Enter Browse Mode [ ]

End If

Link to comment
Share on other sites

Hi, B! Although I cannot give you the answer, I think what you want is a JavaScript validation. You can use JavaScript to make sure that a field has a value (not empty) before the form can be submitted. I used something similar to make sure a password field and the confirm password field had the same values or it rejected the form and would not submit. Unfortunately, I do not "know" JavaScript yet but it was easy enough for me to find a JS script for what I had wanted. You might be able to find what you need (or enough to modify as needed) in the posts or online at a scripts site.

I assume JS has "or" functionality to apply your requirement to any of the 3 search fields.

--ST

Link to comment
Share on other sites

Many thanks for the suggestion. It gets me part way in that the error can be used to display the error page I have provided. However I am having problems getting the extra parameter recognised in the Form I am using. Willl carry on and see if I can solve that part of the puzzle.

Link to comment
Share on other sites

Hi Queue

My solution after your suggestion was to use two scripts as one didn't work as it should thus:

Called by -Script.PreFind

Set Error Capture[On]

If [status(CurrentError)=400]

Exit Script

Endif

This calls my error page because of a hidden -Error call

Then called by -Script.PreSort

Modify Last Find

Set Field [FieldA,value]

Perform Find[]

It may not be good scripting but it works perfectly!

smile.gif

Link to comment
Share on other sites

This topic is 7253 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.