4 Replies Latest reply on Dec 1, 2015 1:19 AM by tkemmere

    Changing a relation


      Dear all,


      A newbe scripting question. I hope someone is willing to get me going. I'm very new to Filemaker as well as scripting, And I'm very much enjoying learning art of building a well functionning database solution. But on this one I have no best path how to tackle things. It is probably quite simple, and that is why I can't find it online easily.


      I have a table account managers. And a related table companies. Managers and companies have names, but the relation is maintained through numbered ID and FID. An account manager wants to assign one of his companies to a colleague. In the layout of that company, he sees his own name. But when he would change his name into that of his colleague, he'd actually be changing his own name in the related accmgr-table.


      How should I best make it so, that when he clicks a dropdown with colleagues, the accmgr-table stays in tact, but the FID in the companies table is adjusted according to the chosen name?


      What I did sofar: User clicks on the dropdown-field accountmanager in companies-layout, and a script is triggered on that: "OnObjectEnter". Then I tried "Show Custom Dialogue" with an Input Field "NewAccountmanager", which is added to the Accountmanager-table. But then I get stuck. Becuase how do I look up that value in the Accmgr-table and put the corrsponding ID into the FID of companies...? Am I on the right track?


      I know it's basic stuff for most of you, and I'm very willing to do my own searching, but it seems rather difficult to find these basic things. I still have to get used to the "way of thinking". I'm sure I'll get there. Thanks for your response.


      Regards, Thomas.

        • 1. Re: Changing a relation

          Good morning.


          I've worked this very same problem. Your scripting has to capture the ID of the newly-created record and then set this FID field to that value.



          1. Show Custom Dialog

          2. Allow to enter a new Account manager

          3. Create account manager in account manager table. (You're on the manager TO)

          4. Capture that new record's ID.

          5. go back to this company layout.

          6. Put the value in this FID field.

          • 2. Re: Changing a relation

            Good evening Jeremy ,


            Thanks for the reply.


            We're on the right way, but in my situation there is no new-record-creation. All Account managers are already in the table Accountmanagers. It's a change of ownership. So step 3 needs to be something with "lookup", but Lookup is not a FM-term.


            Thanks, Thomas.

            (I plan to be back at work tomorrow appx 09:00 Central European Time.)

            • 3. Re: Changing a relation


              I misunderstood. THat happens sometimes☺

              So you're FID field has a dropdown, no?

              You could easily set this drop down value list to include the IDs of the account managers from your account manager table. You can set it to store the ID from the account manager table, but show the name of the manager so the user knows who they are selecting.


              Since you don't need to create any new managers, simply select from what's there. I'd get rid of the dialog box and simply allow the user to choose.


              See my example here. I think I understand now what you're needing.

              • 4. Re: Changing a relation

                Dear Jeremy,


                Great! I'm very grateful for your effort! This does exactly the trick. I made modifications exactly according to your attached .zip and it is working well.


                Theres no Conditional formatting to a pop-up I noiced, (each of the accounmanagers have their repective colour), but I solved that by putting a non-editable instance of the accountmanagers' name behind the pop-up menu, that does have conditional formatting.



                Thanks once again,

                Kind regards, Thomas.