5 Replies Latest reply on Feb 15, 2011 9:54 AM by philmodjunk

    Going Between Windows encountering problem

    bookalaka_1

      Title

      Going Between Windows encountering problem

      Post

      I am trying to create a script that will update my pricebook from stock information I receive. The script will use two tables a Pricebook table and a Stock Notice table and go between two seperate windows lets call them "PBA" and 'STB" . The script is to copy the item code from the stock table /STB and create a new record in the pricebook table PBA, paste to the PBA itemcode  and  after completed a checkbox  is marked  the STB field "Updated".

      In doing this manually I discovered something I never encountered before. if I create a New Record in my PBA table then copy my Itemcode from my STB and paste in the PBA itemcode it works fine. However when I go to my Stock table copy my itemcode then move to the PBA and create new record it will not paste? I can type the code in but the record does not allow me to paste? The information is on the clipboard because I can paste in the Stock table.  I have a long list of items and the only way I can think of doing this is the later.

      What am I missing? 

      Thanks

        • 1. Re: Going Between Windows encountering problem
          philmodjunk

          Hard to say without physically examining your file. Copy and Paste will both silently fail to work if the referenced field is not on the current layout, so that is one possibility. (And your focus might still be on the other window or layout when you tried to paste.)

          Copy and Paste aren't the best options for moving data between your two windows anyway. In addition to the above limitation, if the user copies data to the clipboard and then they run your script, their copied data will be replaced by the itemcode and users can find that both confusing and irritating.

          Instead, use set variable with set field to move data from one layout or window to another:

          Working from your description of two windows rather than just two layouts here and assuming that both windows are from the same file, this is what you might use:

          Set Variable [$ItemCode ; STB::ItemCode]
          Select Window [//specify other window here]
          New Record/Request
          Set Field [PBA::ITemCode ; $ItemCode]

          • 2. Re: Going Between Windows encountering problem
            bookalaka_1

            I get everything to accept the last variable I don't understand how you get the second part of the equation?  The new window is selected  but the set field hasn't worked? In my script  Set Field I can select the "PBA::ItemCode but I don't know how to program the second part ;$Itemcode]

            Thanks for clarification

            • 3. Re: Going Between Windows encountering problem
              philmodjunk

              What version of FileMaker are you using?

              $Itemcode is a variable. I'm using it as a "bucket" to carry the ItemCode value from the current record in one window to the current record in the other window. I create this "bucket" in the first line of the script and store the ItemCode in it from the current record of your current window. The final line of code then takes the value from the variable and puts it in the PBA::ItemCode field of your new record.

              In older versions of FileMaker that do not support variables, you may have to use a global field for this purpose.

              • 4. Re: Going Between Windows encountering problem
                bookalaka_1

                I use 11 advanced. Here is my actual script  seems straightforward not sure why is not working.

                Set Variable[$ItemCode;Value:Inventory_Items::CodeCalc_pk]

                Select Window[Name:"PriceBook_Dev"]

                NewRecord/Request

                Set Field[PriceBook::Code_PB_sp;Inventory_Items::CodeCalc_pk]

                I have tried different fields as the result and all come up blank?

                • 5. Re: Going Between Windows encountering problem
                  philmodjunk

                  Your last line should be:

                  Set Field[PriceBook::Code_PB_sp; $ItemCode ]

                  Once your focus changes to the other window (also true for changing to a layout based on a different table occurrence), you no longer have automatic access to the current record of the previous window or layout. That's why you have to store the value in a variable before changing layouts.