10 Replies Latest reply on Oct 3, 2013 10:22 AM by BruceRobertson

    Using variables between two files!


      I don't seem to find a way to do this!


      I have two files: Products and JobRecords, and everything has been coming together nicely, until I added a last feature.


      I have been doing just fine with a script that handles a copy/paste method to get info from Products and then paste it into Job Records. No problems, and I even added a phantom field to the tab into and copy to make sure my clipboard was empty, avoiding an accidental double item by repeating a paste commend.


      But I want to add a way to track some (maybe 25) of the 2500 items. I can't do that in the Product catalog, but using the line items in my Job File lets me use a summary field to count the sold items and alert me when a set limit is hit. So far so good.


      But now, wanting to get "Track?' info from my Products list, I can't use copy/paste for that second bit of info. And so far all my tests with a variable $track (using $track=products::track?, a simple yes/no field) are failing. I thought maybe I needed to change my drop menu Yes/No field to a basic edit box. Did that, no change. Every time I try using the $track variable in Job Records, it adds the text "$track" but not the word "Yes" or "No" which I expect.


      Insert text does just that; it inserts $track! Set requires a number. Calculated set to text results? Nope!


      What am I missing?


      Thanks for any help,



        • 1. Re: Using variables between two files!

          First of all, you should not use the copy and paste commands in FileMaker when you want to populate record information from one table to another.


          The proper way to do it is setting a variable with the record info you need, then go to the table (layout) and set the field with the variable. This way it is guaranteed that you are setting the field with the right info.


          Back in the day I used the copy/paste method and then I wondered why I had completely mismatched info in fields. If anything else gets on the clipboard you're in trouble. There's no way to guarantee what's on the clipboard. So I haven't used copy/paste for over 5 years.


          Second, you're on the right track. But you need to set two variables:


          1. the track

          2. the yes/no


          Also, you don't need a no. A simple checkbox (with a number one in the field) with a label "Track?" is enough.


          Hope this helps. 



          Best regards,


          agnes b. riley

          filemaker and web development

          zeroblue (http://www.zerobluetech.com/)

          download vCard (http://www.zerobluetech.com/docs/Agnes%20B.%20Riley.vcf.zip)



          FileMaker Certified in 10 and 11 • Member, FileMaker Business Alliance

          T: 877 917-9079 . C: 917-660-7221

          Store (http://store.zerobluetech.com/) | Blog (http://blog.zerobluetech.com/) | Facebook (http://www.facebook.com/zerobluetech) | Twitter (http://www.twitter.com/zerobluetech) | LinkedIn (http://www.linkedin.com/company/zeroblue-technology-solutions)

          • 2. Re: Using variables between two files!

            This implies that there is a Table Occurrence for the table (from the "other" file) in the file where the variable is created. Then you can navigate to the layout based on the TO and set the field. However, if you are navigating to another FILE, you will lose the variable.


            I tend to use script parameters for passing such things. Call a script in the "other" file and set the Script parameter with the variable. In the called script use Get ( ScriptParameter ) to retrieve the value and set to a variable for use in that file.



            • 3. Re: Using variables between two files!

              It would help if you would post a copy of your file or a simplified example demonstrating what you are trying to do.


              It isn't clear what "set requires a number" means.

              However, it is clear that you don't quite have the syntax correct on how to use variables.

              There are two parts of the Set Field script step.

              The part that specifies which field.

              The part that specifies what value to put in the field.

              • 4. Re: Using variables between two files!

                It would help if you would post a copy of your file...


                Okay, no merit badge for me, I see. I thought I was doing pretty well but this is showing me that I have been staying in the shallow end of the pool.


                My database started as a way to help a contractor get his workers out into the field armed with iPads. I started simply enough with FM Go and my already-existing database for his office work and estimating. But revising for the iPad uncovered several things that are just not great when handled on an iPad!


                The first big problem was the need for a pop-up menu to find a part in a list of 2500+ items. Never mind the long story of how trying to find ways to get around a few iPad conventions led me to split the initial project into two parts (JobRecords and Products), I have built a very nice data set that works great on the iPad Mini, and even better on the desktop Mac.


                So while I am quite happy with my solution, I had a flash of inspiration! I have the number of parts sold (line items in the Jobs file showing how many of what parts were sold), so I thought I'd knock together an inventory contrl; form! Great, and it works fine! But wait, Of 2500+ items, only a relative few woud need to be available as stock items. So of course a new field for TRACKING quantities was added in my Jobs file.


                Then add a simple field with the PRODUCTS file to mark any item as worth tracking, yes or no. The default was No. Excellent.


                So my casual idea was going well until I wanted to trigger the tracking in the Estimate! wondered why I couldn't get a variable to grab my one extra bit of data and report back to the Estimate to add that into. My inventory script looks for items added that are marked to be counted.


                Here, then, is a very stripped down version of my pair of files: To see an Estimate example, use the layout menu to find one estimate form. Above the portal where line items are entered, see two buttons: Select Parts and Paste Nw Items. Select Parts will open the Products catalog with two items, one of which is tagged for inventory tracking. It's a list view so just see the highted item and hit the + button to the right. That goes back to the Estimate where you then use the Paste button.


                Note: when the paste command finishes, the script tabs to an invisible empty field and copies that, removing the chance of pasting a double entry by mistake.


                I truly appreciate the tips offered here, but I confess, I'm more confused. I will not quit, but I think I will let my customer tap a button in the Estimate to make an item trackable (the red files next to generator is red to show it's reorder time, Check Scripts to run the Inventory script...)


                So I now have to work to get an idea of why I haven't yet found a way to simply treat a variable as a text ite,, when in fact I have used them to create reports and contracts with variables for naming, etc. Parameters? Never even knew about those, so now to read more.


                Thanks to all...



                • 5. Re: Using variables between two files!


                  Go to Layout [ “Customer Cards” (Customers) ]

                  Set Variable [ $clientkey; Value:Customers::clientKey ]

                  Go to Layout [ “Estimate” (Estimates) ]

                  New Record/Request

                  Set Field [ Estimates::clientKey; $clientkey ]

                  Set Field [ Estimates::status; "New" ]

                  View As [ View as Form ]

                  • 6. Re: Using variables between two files!

                    Here you are setting a global variable (two $$ signs) but then trying to display a script variable ( one $ sign )

                    If you change the set variable step to use the script variable the script will work.

                    The other error is that you are capturing Line Items::track when I think you want to be capturing Products::track

                    • 7. Re: Using variables between two files!

                      A few more things to think about in the attached modified example.

                      • 8. Re: Using variables between two files!

                        Well that took me by surprise! I was coming back to report some changes in my method, then found your MOD fils. Now I see you have handled the adding of the new item chosen, removing the need for a paste command! Slick.


                        Of course now I need to check through the scripts to see how this worked, and I'm looking forward to that.


                        Oddly, I am in a funny situation. I have just ONE client where I can use my FM skills (such as they are). My business is graphic design, and nobody comes to me for database work. However, even with just one place to use whatever I can learn about FM Pro, I'm happy to keep busy with refining my database. In fact, this wish to move data between two separate files only came about because I wanted to "dress up" my database with a method to track inventory! Kind of unimportant to him, but a chance for me to learn something more. Little did I know what a new can of worms I was opening! I'm barely aware of how to relate Tables in ONE file, let alone cross pollinate with a second file. And parameters? I read about them but haven't yet had my "Aha!" moment.


                        So I actually found a way to do all this with use of the script triggers and conditional format options, and it works okay for now. But I DO want to poke more and see how you handles the transfer and field setting with no past command.


                        I do appreciate the fast replies and help offered here, so I will try to add to my skills, and thanks to all.



                        • 9. Re: Using variables between two files!

                          Stumped! I'm trying to uncover where/how the data for $p is gathered?


                          Set Variable( [$track; Value:GetValue($p:1)]. Etc. (I wanted tp paste a few lines of code but that won't work!)


                          I see the improved method, but for some reason I'm missing finding any info on where to set a parameter? I know I have seen it but now I want to find it? Not happening!


                          I realized that my "Min_Qty" data for my inventory really needs to be listed in the Product catalog so that every new added estimate line shows the same number for that item. I added a number field for Qty_Min to my items, and thought I could duplicate the two examples for $item and $track. But several tries, no result. I don't know what the 1 and 2 data refer to? I assume it's lines in a return-sep list? I tried a simple $min = Qty_Min field, but that also fails.


                          I'm seeing many pages of info on how to use parameters but honestly? Not so much on how to establish a parameter, and certainly I'm lost on assigning that number!


                          I know I'm going to stumble onto the way to do this five minutes after I post. That's often the case, but a bit more help will be much appreciated.

                          • 10. Re: Using variables between two files!

                            script param.png


                            Look at the buttons; or any place where you actually select a script to be performed.

                            There is a place at the bottom of the script selector dialog to edit the parameter.