10 Replies Latest reply on Apr 13, 2010 2:58 PM by FMUser

    Going to a contact file from another database

    FMUser

      Title

      Going to a contact file from another database

      Post

      I am new to programming databases but have been learning a lot along the way. I am using Filemaker Pro 10 for my small business and began by implementing a premade solution that Filemaker provided called “Filemaker Business Productivity Solution – Service Edition (BPS)” Which is a collection of separate databases linked together through scripts. The problem that I am having is that over the course of using BPS I have wanted to make several changes, which I have done with a little help from a Missing Manual book. What I am trying to do, the book is no help with this, is to add a field into the Service Database for a contact with a button next to it that I can click and have it take me to that contact in the Contact Database. What I have done to solve the challenge is: I have added the Contact Database to the Service Database as an external data source and added the Contact DB as relationship in the Manage Database area. I know that I am going to have to provide a script and a button to be able to view the Contact form view through use of a button in the Service DB but everything I have tried has failed. I need help to figure this out… I am way to invested to start over with a new database design.

      Thanks for any help…

        • 1. Re: Going to a contact file from another database
          philmodjunk

          "add a field into the Service Database for a contact with a button next to it that I can click and have it take me to that contact in the Contact Database"

          I assume that field is for the contact's name?

           

          Define this field as a global text field.

          Set your button up to perform a script in the contacts file and set it to pass the contents of this global field as a parameter.

           

          Create the script in your contacts file that runs something like this: (I don't have a copy of this template open, so you'll have to substitute actual file and table names from that database.)

           

          Go To Layout [Specify the layout were you want to see your search results]

          Enter Find Mode[]

          Set Field [Contacts::Name ; Get ( ScriptParameter ) ]

          Set Error Capture [on]

          Perform Find[]

           

          • 2. Re: Going to a contact file from another database
            FMUser

            Thank you for the response, I tried your solution and I couldn't get it to work. Essentially, what I have is 2 separate databases 1) Contacts and 2) Services.  I would like to include a field in the Services DB "Product manager" where I can type in the name of the person. I would then like to be able to have a button attached to that field that will take me to the Contact DB and show me this person in from view. The reason for the 2 Databases is due to the way Filemaker made the solution. I am truly stumped... Thanks for any help.

            • 3. Re: Going to a contact file from another database
              philmodjunk

              "I couldn't get it to work" doesn't give me anything to work with.

               

              How didn't it work?

              • 4. Re: Going to a contact file from another database
                FMUser

                I apologize for the lack of information that I provided on the last post. I am having some trouble wrapping my head around this difficulty. So, let me try to be as specific as I can and if I leave something out let me know what info you need and I will try to get it. 

                I am trying to set up a field and button in the ‘service’ DB that when activated will take me to that specific persons’ Form View in the ‘contacts’ DB.  In fact there will be more then one field that I will want to do this for (but all the same action) if I get it to work. I am not planning on using a portal (unless its the only way to do it). I have tried to use a “related records” script but it didn’t seem to do anything, as if I never ran a script. I did try your script and it just does a find (basically it just finds the field with the button and blanks out all the other fields) in the ‘service’ DB and then gives me a continue button to end the script. Then I have to goto the Sort/Unsort button in the Menu bar to get back to where I started. It doesn’t goto the ‘contacts’ DB at all. Here is a copy of the script that I used. 

                 

                Go to Layout[Contact REF::Full Name]

                Enter Find Mode []  -------  I specified --- Contact REF::Full Name [==]

                Set Field [Contact REF::Full Name]

                Set Error Capture [On]

                Preform Find [Restore]  ------ I specified --- Contact REF::Full Name [==]

                 

                I have created a table in “Relationships” called ‘Contact REF’ that is identical to the ‘Contact’ DB so that I could make the relationship from the ‘Services’ DB to the ‘Contacts’ DB.  I defined the ‘Contacts’ DB as a “External Data Souse” in the ‘Services’ DB so that I could do this. In ‘Services’ DB I also named a field “Reference Contact ID” and defined it as global,  which is linked to the “Full Name” field in ‘Contacts’ DB.  I am not sure if I should have used a field name that is the same in ‘Contacts’ or if it matters? 

                 

                At this point, I am thinking that it may be better to have the field look up the name in ‘contacts’ instead of typing it in to the field avoiding mistakes and having the script not find the person. This way I may be able to use a “Related Contact script” to goto the ‘Contact’ DB more easily, of course I am not sure how to do this either. 

                 

                I think the real problem here is the fact that there is two separate Databases otherwise it would be more straight forward. 

                 

                The other concern I have is how does the button running the script know what to look up, like what field it is using as the information to take me back to the other database? It it the proximity to the field or in the script somewhere?  I just put the button close to the field and grouped the button and field together. Not sure if this is the right answer. 

                 

                I think that all the info that I have at this point, if I am leaving out something let me know and I will find the answer. 

                 

                Thank you for you help, I am becoming increasingly frustrated and this is the only place I have to look for help, so I am happy there is a community to reach out to.

                • 5. Re: Going to a contact file from another database
                  philmodjunk

                  Well your script has significant differences from my original post and that's why it didn't work.

                   

                  By the description you posted, it also sounds like your script has Enter Find Mode [Pause] which will leave you stuck in Find mode until you click Continue (Blue button in the status area) or click the (numeric keypad's) enter key to continue the script.

                   

                  Let's take another look at the original suggested script:

                   

                  Go To Layout [Specify the layout were you want to see your search results]

                  Enter Find Mode[] Note that there is nothing in the brackets, no pause, no restore

                  Set Field [Contacts::Name ; Get ( ScriptParameter ) ] This step only works if you pass the contact name as a parameter to this script.

                  Set Error Capture [on] This step disables Filemaker error dialog that can halt your script here if no records were found or no criteria were entered.

                  Perform Find[] Again, no Restore, No pause here.

                   

                  This script is written so that you don't have to add the table occurrence to your first file that connects to the external source like you've set up. You can use your new table occurrence if you want, but then you'll also have to set up layouts for searching and displaying the data in your second file. Instead, you can put this script in your contacts file and perform it with a button in the first file. That button has to pass the contact name as a parameter to this script. If you choose to create a layout for this in your first file, you can still use this script, just keep it in the same file and specify the new layout in line one.

                  • 6. Re: Going to a contact file from another database
                    FMUser

                    Ok I redid my script to read...

                     

                    Go to Layout[Contact REF::Full Name]

                    Enter Find Mode []

                    Set Field [Contact REF::Full Name; Get (ScriptParameter )]

                    Set Error Capture [On]

                    Preform Find []

                    When I run this script nothing happens - the first field (not related) blinks but everything just stays the same. Do I need to specify what the 'ScriptParameter' is? 
                    As for the first line "Go to Layout[Contact REF::Full Name]"  I have to specify it as "Layout name by calculation..."  to get [Contact REF::Full Name] because the 'Contacts' DB does not show up. This is not the case with line 3 "Set Field [Contact REF::Full Name; Get (ScriptParameter )]" where it will bring up the specify field window and I can chose the 'Contacts' DB from there as well as the "Full Name" Field. 

                    • 7. Re: Going to a contact file from another database
                      philmodjunk

                      In which file did you create this script.

                       

                      "As for the first line "Go to Layout[Contact REF::Full Name]"  I have to specify it as "Layout name by calculation..."  to get [Contact REF::Full Name] because the 'Contacts' DB does not show up."

                      Suggests that you have put this script in the wrong file. You'll either need to create a layout in this file for this purpose or you'll need to move this script to the other file. (There's an import script tool in script manager that can do this for you.)

                       

                      "Do I need to specify what the 'ScriptParameter' is? "
                      Your button needs to be set up to pass the contact name as the script's parameter. When you set up a button to run this script, you'll see a box at the bottom for specifying a parameter. Click the edit button next to it and select the field where the user is entering a contact name.
                       
                      Note: Your button is in the service file and the script it performs is in the Contact file. When you set up a button to perform a script you can select a script in another file and pass information to it as a script parameter. This is what I am suggesting you do here.
                      • 8. Re: Going to a contact file from another database
                        FMUser

                        Ok I made the changes that you suggested I rewrote the script in the ‘Contacts’ DB and it now looks a bit different:  “Name From Promotion Contact”

                         

                        Go to Layout [“Form View” (Contacts)]

                        Enter Find Mode []

                        Set Field [Contacts::Full name; Services:: Promotion Contact]

                        Set error Capture [On]

                        Perform Find []

                         

                        I also changed the button in the ‘Service’ DB  and specified the script called “Name from promotion contact” that I made in the ‘Contacts’ DB --See above-- and set the Optional script parameter to “Services:: Promotion Contact”.  Also in the 'Contacts' DataBase Relationships I added the ‘Services’ DB as an External Data Source but didn't link it to any fields.  The “Promotion Contact” field in the ‘Services’ DB is set to Global.  I am still not seeing anything happening when I click on the button?  I have a name in the “Promotion Contact” field that exists in the ‘Contacts’ DB and everything appears to look right, but nothing happens?  I don’t know what I am doing wrong?

                        • 9. Re: Going to a contact file from another database
                          philmodjunk

                          It may be that you just need to add one line to the end of your script:

                           

                          Select WIndow [Current window]

                           

                          So that the window for your contact file pops to the front.

                           

                          If you are passing Services:: Promotion Contact as a script parameter, you don't need the extra table occurrence because you can change line 3 to:

                           

                          Set Field [Contacts::Full name; Get ( ScriptParameter ) ]

                           

                          (What you have should work, it's just that you can pass this name as a parameter or use your added table occurrence to refer to it, you don't need to do both.)

                           

                          Another check you can do is to remove the Set Error Capture step and see if any error messages pop up.

                          • 10. Re: Going to a contact file from another database
                            FMUser

                            I want to Thank You for all your help I have got it working and added two more fields to link back to contacts, they are all working perfectly, I truly learned something.  Thank you again for all your patience.