4 Replies Latest reply on Jul 30, 2009 6:16 AM by BetoBoton

    Set Field to (Find it)

    BetoBoton

      Title

      Set Field to (Find it)

      Post

      Hi 

       

      I'm a "novice"  with FMP, and I'm on a Mac with FMP 9 Adv. so please be aware of possible silliness in my questions.

       

       

      Using the ready made Business Solution for Services from FM, and specifically the contacts.fp7 I'm trying to create a new Text field called "Referrer" which is the "Full Name" ("First Name" + "Last Name") of the same record (self referred) OR here comes the question:

       

      I need to  FIND, in the SAME contacts Table  a contact record via First Name field and/or Last Name field to fill this field.

       

      (This means the person who referred this client, must be a previous client or it is mandatory to be "self-referred" 

       

      I have no idea where to start.

      Any suggestions that would point me to  perform a "find script" starting with the letters I type into the field in the contact form. 

      Do I need to create this find in a "new dialogue or window" ? 

       

      My learning style is by example - does someone knows of book, blog or any other place where I can find an example/explanation of finding something while inserting new data in browse mode...

       

      Thanks a lot for any help (I'm lost...)

       

      Beto Boton 

       

        • 1. Re: Set Field to (Find it)
          TSGal

          BetoBoton:

           

          Thank you for your post.

           

          First of all, everyone here is in some stage of learning FileMaker Pro, so no question is silly.

           

          In your Contacts table, pull down the View menu and select "Find Mode".

           

          If you enter just the information into the First Name field, you will see all records where the First Name field contains those contents.  If you enter information into the First Name field AND the Last Name field, you will only find those records that have that data in both the First Name field AND the Last Name field.  I have a feeling you already know this.

           

          Therefore, enter the information into the First Name field, pull down the Request menu and select "Add New Request".  Now, enter the information into the Last Name field.  When you press return, it will look in the first request for all records in the First Name field, and in the second request, all records in the Last Name field.  In other words, it will look for the information in the First Name field OR the Last Name field.

           

          Let me know if you need clarification for any of the above steps.

           

          TSGal

          FileMaker, Inc. 

          • 2. Re: Set Field to (Find it)
            BetoBoton
              

            Thank you very much for your answer, it is very valuable and already gave me some clues on achieving my goal to create a script to perform this operation.

             

            Perhaps I did not explained it properly,  but what I have in mind is an "auto complete" of a field in browse mode WHILE a new record is created or modified.

             

             4 fields

            First Name. Last Name and Full Name and Referred by  fields.

            The scripts will perform these steps:

             

            1- Full Name = First Name + " " + Last Name 

            Question: Where do I perform the script to set the Full Name field to the result above? As a button on the Last Name field?

             

            2- By default on the record the client is "self referred".

            Here I need to assign automatically after the Full Name input "Referred by" field to the value of Full Name Field.  The client here is referred to the service by himself.

             

            3- IF I TYPE the letter "R" for example inside the Referred by field it will bring on a drop down ALL Clients Full Name already on the database using the Full name field as source.

            This is the script I the most difficulty with. since from what I understand the drop down list is a fixed entity with a list of whatever you assign previously to it, AND in Browse mode, while I'm entering the new client's data I'm not performing a "FIND".

             

            So this Referred by field is the result of the "finding an already existing client" by typing initial letters of the name "R" or "Rob" or "Robert" n the Referred by field, and if I don't type anything there it is by default the same name as Full Name field.

             

            I hope someone will understand this, and bring some light to this matter,

             

            Any suggestions on how to achieve these tasks are welcome.

             

            Cheers

            Beto 

             

             

             

            • 3. Re: Set Field to (Find it)
              TSGal

              BetoBoton:

               

              Thank you for the clarification.

               

              1 - For Full Name, you can make that a calculation field with the formula:

               

              First Name & " " & Last Name

               

              ...or, if both values need to be entered,

               

              If ( IsEmpty (First Name) or IsEmpty (Last Name) ; "" ; First Name & " " & Last Name )

               

              If this is to be auto-entered, then enter this information into the Auto-enter calculation and be sure to uncheck the option "Do not replace existing value.."

               

              2 - Using the same information as above, set the Auto-Enter calculation to be "Full Name".

               

              3 - A drop-down value list can either be a static list, or it can be based upon a field.  Set a relationship to the same table, and use the value from the second table occurrence.  This will allow you to see all records in the current table.

               

              Let me know if you need clarification for any of the above steps.

               

              TSGal

              FileMaker, Inc. 

              • 4. Re: Set Field to (Find it)
                BetoBoton
                  

                First of all thank you very much for taking the time to answer my questions.

                 

                I figured out a way to do what I want to achieve.

                I'll publish it here so people doing a search on the net can find this thread and perhaps have a head start on their own project.

                 

                NOTE: The script is NOT FULL PROOF YET it is only a "start"

                 

                The purpose is to Set a Field on a table based on Another Field ON THE SAME TABLE.

                This means I want to Set a Field from a Found Set.

                Some defaults where assumed here to fit my own purposes like "no records found, and only 1 matching result, but I believe you can figure out how to fix this for your own purposes.

                 

                I realised the way to achieve this was to create a new layout where the FIND could be semi-automatically performed.

                I say  semi-automatically because if you find MANY matches you can select from them with the mouse.

                 

                Please disregard useless info inside the script.

                 

                Cheers All

                Beto Boton

                 

                #Find Referee 

                #Set a Field to The Contents of a Find Result 

                Set Error Capture [ On ] 

                #$theRecordID reflects the Record Number + 1 since it stars at Record ID 2 on the auto-count for some reason. I have no idea 

                how to locate the proper record by other means 

                //  Set Variable [ $theRecordID; Value:Contacts::Contact ID ] 

                Set Variable [ $theRecordID; Value:Get ( RecordID ) ] 

                #$who is the "Self Referred" contat full name 

                Set Variable [ $who; Value:Contacts::Full Name ] 

                #The $theRecordID is the client ID (not the referer) 

                Set Variable [ $SelfReferred; Value:Contacts::Full Name ] 

                Set Variable [ $SearchRequest; Value:Contacts::Refered by ] 

                New Window [ Name: "Find A Referee"; Height: 400; Width: 1000; Top: 10; Left: 10 ] 

                Go to Layout [ “Find Referee” (Contacts) ] 

                Enter Find Mode [  ] 

                Set Field [ Contacts::First Name; $SearchRequest ] 

                Perform Find [  ] 

                #If you don't find any Referee it is "SELF-REFERRED" by default. 

                If [ Get ( FoundCount ) = 0 ] 

                Show Custom Dialog [ Title: "Message"; Message: "No Referees Found with this Criteria"; Buttons: “OK”, “Cancel” ] 

                Close Window [ Current Window ] 

                Select Window [ Current Window ] 

                Show All Records 

                //  Go to Record/Request/Page [ ($theRecordID - 1) ] 

                [ No dialog ] 

                Go to Record/Request/Page [ ($theRecordID) ] 

                [ No dialog ] 

                Set Variable [ $who; Value:Contacts::Full Name ] 

                Set Field [ Contacts::Refered by; $who ] 

                Enter Browse Mode 

                Exit Script [  ] 

                End If 

                # 

                #If you find Only 1 match for Referee it is "The Match" by default. 

                If [ Get ( FoundCount ) = 1 ] 

                Show Custom Dialog [ Title: "Message"; Message: "Only 1 Referee Found with this Criteria"; Buttons: “OK”, “Cancel” ] 

                Set Variable [ $who; Value:Contacts::Full Name ] 

                Close Window [ Current Window ] 

                Select Window [ Current Window ] 

                Show All Records 

                //  Go to Record/Request/Page [ ($theRecordID - 1) ] 

                [ No dialog ] 

                Go to Record/Request/Page [ ($theRecordID) ] 

                [ No dialog ] 

                Set Field [ Contacts::Refered by; $who ] 

                Enter Browse Mode 

                Exit Script [  ] 

                End If 

                # 

                # 

                #Difficult here 

                Pause/Resume Script [ Indefinitely ] 

                Set Variable [ $who; Value:Contacts::Full Name ] 

                Commit Records/Requests 

                Close Window [ Current Window ] 

                Select Window [ Current Window ] 

                Show All Records 

                Go to Record/Request/Page [ ($theRecordID - 1) ] 

                [ No dialog ] 

                Find Referee 

                Set Field [ Contacts::Refered by; $who ] 

                Show Custom Dialog [ Title: "This is the current record"; Message: "Contact ID  is: " &  Contacts::Contact ID  &  Contacts::Full 

                Name & "The Rereree is: " & Contacts::Refered by; Buttons: “OK”, “Cancel” ] 

                Enter Browse Mode