7 Replies Latest reply on Jun 23, 2017 7:13 AM by pietergorisio

    Set Field does't seem to push data into the wanted field

    pietergorisio

      Hi FM'ers,

       

       

      I know, I'm busy with a lot of questions lately. But I'm building a touch device interface and running into a heap of problems lately.

      I was hoping you guys could think along with me.

      Here is a graph of one of the many relationships.

       

      Screen Shot 2017-06-22 at 19.25.36.png

       

      What I'm trying to do is get in Invoices::ContactIdFk (number) the ID that you can find in Contacts_Invoices::Id (Number, auto serial)

      with the Set field (on button click). It seems it runs the script but ContactIdFk stays empty.

      I'm trying to select the client for a specific invoice from a list with all clients.

       

      The script I use when button click is:

       

      Set Field [ Invoices::ContactIdFk ; Contacts_Invoices::InvoiceNumber ]

      Go to Layout ["CreateNewInvoice" (Invoices) ]

      Go to Object ["Object Name: "tab-chooseclient" ]

       

      Hope you guys could teach me another thing or two. Because I don't see what I'm doing wrong here.

      But it might be a foolish mistake

       

      Much appreciated!

        • 1. Re: Set Field does't seem to push data into the wanted field
          philipHPG

          If the Invoices::ContactIDFk field is blank then there is no relationship between Invoice and Contacts_Invoices (as that is what your relationship is based on) so your script step won't work as one side or the other doesn't have a related record. If you're on a layout/portal based on Invoices there is no related Contacts_Invoices record to pull the Contacts_Invoices::ID field from, or, if you're on a layout/portal based on Contacts_Invoices there is no related Invoice record in which to Set the ContactIDFk field.

           

          Depending on what your process is there are several different options for this.

           

          If you're creating the Invoice starting from a Contact record you can save the Contacts::ID in a variable and then assign that to the Invoice when it is created. Or, and based on your object names in the script snippet you provided it seems like this is what you are doing, on the Invoice there can be a client picker that allows the user to select the client and then it fills the Contacts::ID into the Invoice::ContactIdFk field.

          • 2. Re: Set Field does't seem to push data into the wanted field
            philmodjunk

            In the example posted you are setting contactIDFk to invoice number not ID.

            • 3. Re: Set Field does't seem to push data into the wanted field
              pietergorisio

              Hi guys, thanks for the response. I tried to work a bit with the information given but can't get to a solution that works.

              I hope someone can show me how to do it so I can learn from that.

              In attachment a testfile (login: Admin pw:8710).

               

              I'm trying to get my

               

              Layout: "CreateNewInvoice" Tab: "Klantgegevens" Link: "Toon alle klanten" to show a list of all clients where I can pick one from using the search.

              Then it would need to populate the ContactIdFk field on Tab: Klantgegevens.

               

              I tried working with a global field but didn't succeeded since it showed me the same value over all the invoice records.

              Been trying to fix this for 1,5 day and it's driving me crazy. I am going on a 3 day Filemaker development course where they will teach me more about relationships but that doesn't help me at this moment of course. Trying to learn as much as I can lately. Course doesn't have a start date yet. Hope it will start soon.

               

               

              Much appreciated.

              Regards,

              Pieter

              • 5. Re: Set Field does't seem to push data into the wanted field
                pietergorisio

                Thanks for pointing out. I copied the wrong information sorry. Was confused by all the windows that were open.

                • 6. Re: Set Field does't seem to push data into the wanted field
                  philipHPG

                  Hi, Pieter,

                   

                  I took a look at your file at made a few modifications:

                   

                  1. I added a Set Variable step in the "Select Client for Invoice" script that saves the current Invoice ID to a global variable before switching to the layout where they select the client.
                  2. I created a script "Select Client for Invoice" that saves the Contacts_Invoices::Id from the selected Contact and then switches back to your CreateNewInvoice layout, finds the original invoice (using the global variable from above), and switches back to the Choose Client tab.
                  3. I attached that script to the client's name in the ChooseInvoiceClient layout, so that clicking on the name takes you back to the invoice. (I'm sure you'll change it so that it doesn't show the client's ID, but rather their name.)

                   

                  Hopefully this helps you see how it could be done. There are other options you might want to consider for choosing the client, such as a popover (as is used in FileMaker's Invoices template), or a card window (if you are using FM 16), or even a modal dialog window. These would allow you to choose the client without switching the layout completely.

                   

                  Hopefully that will help you get started.

                   

                  Thanks,

                   

                  Philip

                  • 7. Re: Set Field does't seem to push data into the wanted field
                    pietergorisio

                    Hi Philip,

                     

                     

                    many many thanks for your help. Works flawless and I will definitely learn from this.

                    I understand there are often more approaches you can follow with all their benefits and downsides. But at least now I know one possible solid solution and I can learn from it.

                     

                    Again much appreciated.

                    Regards,

                    Pieter