eDog Posted June 18, 2003 Share Posted June 18, 2003 I'm an FM amateur. I'm trying to create a script that will go to a specified layout, show only records that have a specified value in specified field, and sort those records by a date field. Sounds easy. In fact, part of it is. Getting to the layout is easy. Sorting is easy. But I cannot figure out how to run the "Find" portion of this in a script. Where do I specify in the script what criteria I am trying to find? If I could use an IF statement it would be written something like: IF "status"="active", SHOW THE RECORD otherwise DON'T SHOW THE RECORD. It's the Show the record part that I don't get. Can you offer any advice? (Please don't say read the manual--I did--several times.) :-) e Link to comment Share on other sites More sharing options...
Doug Posted June 18, 2003 Share Posted June 18, 2003 One method of scripting a find ... Enter Find Mode[] Set Field("status", ""Active"") Perform Find[] (Note, uncheck Restore Find Requests and Pause) Another way would be to manually perform the find then create the script with the Perform Find using the Restore Find Requests. Link to comment Share on other sites More sharing options...
slstrother Posted June 18, 2003 Share Posted June 18, 2003 Perform your find and sort manually first. Then create a script Go to Layout[your layout] Perform Find[Restore] Sort[Restore, No Dialog] Scriptmaker will store the last find or sort performed. You can store only one find and/or sort in a script. Hope this helps. Link to comment Share on other sites More sharing options...
eDog Posted June 18, 2003 Author Share Posted June 18, 2003 I used Doug's method ('cause it was first) and it worked perfectly! It also gave me a lot of insight into the logic of Scriptmaker so future scripts should be a bit easier. Thanks for the lesson! e Link to comment Share on other sites More sharing options...
FileMakin' Tom Posted June 19, 2003 Share Posted June 19, 2003 Scripting finds which are always the same are easy, as was the case in this example. If the find data changes from circumstance to circumstance, then one must provide a find screen where the user can interact to set the find criteria. For instance, when a date range is needed, it can vary, so the user must input the range then execute the find. But if the data to find is static (always the same), then a predetermined, scripted find works just fine. Tom Link to comment Share on other sites More sharing options...
ADDSuzy Posted May 1, 2007 Share Posted May 1, 2007 Hi Tom, I've followed this thread and I'm trying to do just that: have a "Find an Item" for the user. Each find will be different. What do you mean by "provide a screen" for them to do the find? Does this involve one of those dialog thingys? (I'm a newbie coming from MS Access). Thanks! Link to comment Share on other sites More sharing options...
AHunter3 Posted May 1, 2007 Share Posted May 1, 2007 Hey, ADDSuzyy! Are you aware that you're responding to a 2003-vintage thread? Ol' FileMakin' Tom hasn't been around these parts since fall of '05. Those folks were probably using a significantly older version of FileMaker. Certainly slstrother's statement that you can only store one Find or Sort request in a script would be incorrect these days! Now: how would each find "be different"? Ideally there should be some rule or rationale for the way in which it would be different for one person as opposed to another, since you kind of want to avoid "Mary Sue" scripts that diverge in function according to whether the current user is "Mary Sue", etc etc. Is it by Department? Is it a case of "I want them to find their own records"? EDIT: Oh, do you mean "How does one give the user an opportunity to SPECIFY what to find"? A "Find Screen" is just like any other screen, except that generally you don't want it to be chock-full of buttons that the newbie user could click and navigate away from the layout while the script is still paused and waiting. Architecturally, though, it's a layout with fields on it, and your user clicks into fields and types in their Find request and then hits a "Continue" button to tell the script to pick up where it paused and actually perform the Find, based on parameters the user entered. Does this involve one of those dialog thingys? Well, it can. If the user is only to be given Find options of what value to put in 3 or fewer fields, AND you don't need to give the user a value list, just a blank for each field for them to type in, then yes you can use a Custom Dialog. Often enough, though, you want your user to pick from values of a value list, and/or you want to give your user the choice of more than 3 fields to specify their Find Request in, and in those cases you'd want to use a layout rather than a dialog. Link to comment Share on other sites More sharing options...
ADDSuzy Posted May 1, 2007 Share Posted May 1, 2007 Geez, time flies ;-) Well, I would LIKE an automated scripting-thing so that the User runs the script, types in the item they want to find, say Gloves, and gets back a sorted, summarized report of all the different gloves ordered and the total #. etc. I have a report that does it - sorta - but now how do I incorporate a flexible find? Oh, and I am using FM 8.5 Link to comment Share on other sites More sharing options...
AHunter3 Posted May 2, 2007 Share Posted May 2, 2007 a) Create "Find" layout. This is actually optional if your users aren't dumb as a stump: you CAN just utilize their regular data-entry layout and let it double as a Find-parameters screen, if you can reasonably expect them to comprehend that there's a difference between Find Mode and Browse Mode, and that there's a difference between normal data-entry mode and the state of being in mid-script. Umm, you should probably make a "Find" layout A "Find" layout would be a layout that contains the fields in which the users would input their Find requests. The fields would therefore be formatted to allow cursor entry in Find Mode. The "Find" layout might have, in big bold letters, instructions right there on the layout. b) Script does this (give or take): Allow User Abort [OFF] Go to Layout [Find Screen] Enter Find Mode [Pause] Set Error Capture [On] Perform Find [] If [Get(LastError)= 400 or Get(FoundCount) = 0] ..Show Custom Dialog [Case (Get(LastError) = 400, "Operation cancelled because you did not enter any Find requests!", "No records were found matching the parameters that you entered") / "OK"] ..Go to Layout[original layout] ..Exit Script End If Sort [no dialog, ] Go to Layout [Report Layout] Print Setup [Restore, no dialog, ] Show/Hide Status Area [show] Enter Preview Mode [Pause] Print [] Enter Browse Mode [] Go to Layout [original layout] Link to comment Share on other sites More sharing options...
ADDSuzy Posted May 10, 2007 Share Posted May 10, 2007 Hello AHunter3, Sorry about the delay, but I had real work to do ;-) Anyhow, your script works like a charm. Not only did it help me getting this Find Report to work, it helped educate me about using the Perform Dialog function and in general how flexible Scripts could be. In this instance, I have to say that it seems easier - once you get the idea - than writing Visual Basic! Thank you Muchly! Link to comment Share on other sites More sharing options...
dosruedas Posted June 8, 2007 Share Posted June 8, 2007 this is very similar to something i am attempting to do in my DB with one caveat... i would love the find based on the user name when they sign in remotely. so when they login, FM runs a script that finds their particular accounts and returns a list of accounts sorted by next call date. i have this all sorted out except for the Login User... i can't figure out how to draw a connection between the Rep Field and the User... any help would be immensely appreciated! smiley-laughing Link to comment Share on other sites More sharing options...
Recommended Posts