smokeyjones Posted December 18, 2009 Posted December 18, 2009 Hi, I need help creating a simple script which I have no idea how to dispute my efforts of searching through the forums. The database I'm made has only 1 table. Field A contains a list of Last Names. Field B contains a list of First Names. Field C contains a list of Last Names then First Name separated by a space. I need a script that takes value from field C and searches records matching Both A & B fields, or at least find matching records for Field A. Any help is appreciated, if anyone could make a sample document of this so I can see how it works it would be wonderful.
bcooney Posted December 26, 2009 Posted December 26, 2009 Just to confirm, "Field A contains a list of Last Names" and by that you mean that Field A contains the last name for that record. Just one last name, not a list. I would also assume that Field B contains just the first name. Field C should be a calculation field, result text: LastName & ", " & FirstName. You can do the find in Field C, but why? Why not just search the proper field?
Newbies kaliko Posted December 28, 2009 Newbies Posted December 28, 2009 …Why not just search the proper field? Hi bcooney. I have sought the same thing as smokeyjones over the past few years, and it's one area I wish was better implemented in FMP: Finding stuff with scripts! I know that smokeyjones had a very simple example set of fields, and you suggested he should just use the clunky old FMP empty field method of Finding, but I would like to widen the scope of his question and hopefully you can shed some light on this problem! : THE QUESTION in essence is this: How can one script a find action which uses a value from a field or a variable (either $$ or $) or a dynamically generated calculation? When I use "Perform Find [Restore]" as a script step, I cannot seem to get the Find to accept a calculation, a field value, or variable. Am I missing something? Is there a trick to this? It must be a common thing to want to do, I would imagine. thanks in advance.
comment Posted December 28, 2009 Posted December 28, 2009 See if this helps: http://fmforums.com/forum/showpost.php?post/313391/
bcooney Posted December 28, 2009 Posted December 28, 2009 Hey now, don't be dissing FM's Find mode! : Scripted finds are wonderful things but you put yourself in a bit of a corner as the developer. You need to predict what Finds the user will need. I reserve scripted finds for the common, but somewhat complicated finds that a user will need using the system. In fact, in a recent system, we have a layout that has many calculation results, an Overview. Clicking on the calculation (the result is a button) performs a scripted find that takes the user to the records that comprise the total. For example, all records that are of this type and do not have a data complete but do have an approved status. Having a scripted find here helps the user tremendously. However, the user still can do a straight up FM Find using a dedicated Find layout. Anyway, comment's link shows the technique necessary for a scripted find. In fact, I never use Perform Find (restore) because I cannot see what is restored in Scriptmaker without going into the script step. So I always use Enter Find, Set Field, Perform Find construct, because it is more apparent code to read.
Newbies kaliko Posted December 29, 2009 Newbies Posted December 29, 2009 Thanks comment and bcooney for the steps you presented. That's the method I have used up to this point also, but I just wish there were a way to do it without having to have an extra find layout hidden somewhere which the script has to jump to in order to find stuff "behind the scenes". And thanks again bcooney for your thoughts about predicting client needs. In this case, I am writing a database for myself (!) which means I want to have some cool bells and whistles to play with, hahaha. What I am trying to do is this: have a search layout with a simple "search for text" field onscreen and a set of, say, three radio buttons, one each for the field which I want searched (in related tables), but which have no fields on the current layout. I want the script to go off and perform the search in the background (without having to build a special hidden layout for it) and then come back with the results. Those results are then dynamically put together in a webviewer object and presented to me, the user. I have been using quite a lot of webviewer/html/css stuff in the past couple of years to do all my presentation onscreen. I love the way I can make my data look! There are still many limitations using the webviewer (the worst of which is no feedback into the database unless you use a plugin like Reactor), but I still like it for display. Well, sorry, I wandered off topic a bit. But thanks again to you both and happy new year 2010!
comment Posted December 29, 2009 Posted December 29, 2009 You don't need any "extra find layout hidden somewhere" for a scripted find. You just need *a* layout of the table to search, in order to establish context (i.e. which table to search).
smokeyjones Posted January 5, 2010 Author Posted January 5, 2010 thanks for the link comment, but when i tried to make the script working I encountered a small problem. Go to Layout["Resumo do mes"](Expense Report)] Enter Find Mode [] Set Field [ Date of End of Month ; ] Perform Find [] Sort Records [Restore; No dialog] for the I tried to use a field that is different from the Date of the Month field, for the sake of that example but it does not seem to work. However if I enter a specific value in place like 01/05/2010 then it works, what am i doing wrong?
comment Posted January 5, 2010 Posted January 5, 2010 When you are in Find mode, only global fields have values. If you want to use a value from a non-global field as search criteria, you must grab it while still in Browse mode, e.g. Set Variable [ $searchValue ; Table::Field ] Enter Find Mode [] Set Field [ Table::Field ; $searchValue ] Perform Find []
smokeyjones Posted January 5, 2010 Author Posted January 5, 2010 for some reason Setvariable does not let me set a target field but only the calculation... I'm still not sure how this works, So I've uploaded a simple test I made to try this out, could you take a look and see where I did wrong? Find_Test.fp7.zip
comment Posted January 5, 2010 Posted January 5, 2010 Set Variable[] does not have a target field - the target is the variable being set. Find_Test.fp7.zip
smokeyjones Posted January 5, 2010 Author Posted January 5, 2010 Thank you! I confused search value with calculated value there.
Recommended Posts
This topic is 5435 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 accountSign in
Already have an account? Sign in here.
Sign In Now