1 2 Previous Next 17 Replies Latest reply on Nov 14, 2016 8:28 AM by rossdavis

    Script will not pass variables to fields

    rossdavis

      Hi All -

       

      Background:

       

      Filemaker Pro 14

       

      Creating a "Shopping Cart" type app to be used by our custodial staff to order supplies from our warehouse.   User start with an order form, then via a script go over to the supplies form.  Users then enters the quantity for a supply item and the clicks a button (with the following script assigned) to add this item to their order.  I want to use this method so that we may display a picture of the item for quick identification purposes.

       

      3 Tables:  Orders, Orders_Line_Items and Supplies

      Orders 1 to Many with Orders_Line_Items

       

      My plan does NOT intend to use relationships to display details from Supplies  on Orders_Line_Items.  We need to keep the data "as is" on the order form.

       

      The attached script has some errors in that the fields never get assigned to values from the variables.

       

      Would someone point out my error?  Note the $$order_number value was set by me to 10 just for testing purposes.  It usually set by another script.

       

       

      TIA

       

      Ross

        • 1. Re: Script will not pass variables to fields
          mikebeargie

          Have you run it through debugger to see if any errors are returned?

           

          What about the data viewer to confirm that the variables are being set properly as well?

           

          Line 15 - $number_orderd

          spelling mistake is the only thing I see.

           

          You can error check along the way by adding things like (for example, adding between lines 10/11) :

          If [ Get(LastError) <> 0 ]

            Show Custom Dialog [ "ERROR" ; Get(LastError) & " error occurred when setting order number" ]

          Else If [ tOrdered_Line_Items::order_number = 0 or IsEmpty( tOrdered_Line_Items::order_number ) ]

            Show Custom Dialog [ "ERROR" ; "Could not set proper order number value" ]

          End If

          • 2. Re: Script will not pass variables to fields
            rossdavis

            Damn fingers! 

             

            Still no change.

             

            Running FM 14 Pro - not Advanced so I don't believe I can run the debugger or the data viewer. 

             

            Steps 4, 5, and 6 do show the variables appropriately.

             

            Ross

            • 3. Re: Script will not pass variables to fields
              philipHPG

              We can't see lines 10, 11 and 12 completely however it looks like you are using a variable to determine the repetition number in Set Field (at least on lines 10 and 11). Are those really repeating fields or did you put the variable in the wrong part of the script step configuration?

               

              It also looks like you are essentially setting a boolean value. Do you intend to simply set the field to the variable value? You might want to look at how the Set Field script step works:

               

              Set Field [ Table::FieldName ; NewValue ];

               

              it seems like you are using perhaps trying:

               

              Set Field [ Table::FieldName ; Table::FieldName = NewValue ] which turns out just to assign a boolean value.

              1 of 1 people found this helpful
              • 4. Re: Script will not pass variables to fields
                mikebeargie

                Add the error checking I noted then and see if you get an error.

                 

                Also, when you manually type in those fields, any error?

                • 5. Re: Script will not pass variables to fields
                  erolst

                  It seems you are trying to write into fields from "tOrdered_Line_Items" (lines 10-12). While the layout the script switches to in line 7 is also called "tOrdered_Line_Items", it is based on a table occurrence "tOrdered_", so there is a mismatch (or as we might say in German: a "Mischmasch" ;-)

                   

                  Of course this may be an artefact of the script display and the line breaks, but your exotic nomenclature doesn't help ...

                   

                  EDIT: is it just me, or are the values you're trying to write in lines 10-12 Boolean expressions? If so, is that on purpose?

                  • 6. Re: Script will not pass variables to fields
                    rossdavis

                    Hmm...  Thought I was following these instructions I found on this forum

                     

                      If your variable is named $$GlobalVariable, use:

                         Set FIeld [ Tx::PTIdNumber FK ; $$GlobalVariable ]

                         When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

                     

                    Completely wrong?

                    • 7. Re: Script will not pass variables to fields
                      rossdavis

                      Not trying to write boolean - just numbers and text.

                      • 8. Re: Script will not pass variables to fields
                        philipHPG

                        To explain a little further:

                         

                        I am guessing that the full line 10 looks like this:

                         

                        Set Field [ tOrdered_Line_Items::order_number[$$order_number] ; tOrdered_Line_Items::order_number = $$order_number ]

                         

                        There are likely two problems with this:

                         

                        1. You are using $$order_number to specify a repetition for the order_number field. Unless this is a repeating field, this is not what you want. (And if it is a repeating field, we will probably have a number of things to say about that.)

                         

                        2. You are actually setting the order_number field to a calculation that is checking whether the current value of the field matches the order_number variable. So the result will be true (1) or false (0). You don't need to do an assignment within the Calculation portion - you just tell it which value to assign to the specified field.

                        1 of 1 people found this helpful
                        • 9. Re: Script will not pass variables to fields
                          rossdavis

                          Perhaps I've been setting the variables using the incorrect process.  I've been using the prompts from the script builder.  Do I need to type manually?

                          • 10. Re: Script will not pass variables to fields
                            philipHPG

                            Yes, notice the part where it says: "Do not click the Specify button next to the repetition box." It looks like at least on lines 10 and 11, the Specify button was clicked and the variable was pasted in. Please remove that.

                            • 11. Re: Script will not pass variables to fields
                              mikebeargie

                              If you are not using repetitions, then don’t specify a repetition value under set field. Else you could be trying to set a repetition that does not exist.

                              • 12. Re: Script will not pass variables to fields
                                erolst

                                philipHPG wrote:

                                notice the part where it says: "Do not click the Specify button next to the repetition box."

                                Well, you know what usually happens when things have a "Don't touch" label next to it …

                                • 13. Re: Script will not pass variables to fields
                                  rossdavis

                                  Thanks to all. Problem solved!  Was over thinking this a bit.

                                   

                                  Anyway to give credit to more than one person for the correct answer?

                                  • 14. Re: Script will not pass variables to fields
                                    philipHPG

                                    As the instructions indicated, when configuring a Set Field script step there are two Specify buttons that need to be clicked. (see first image below) The first identifies the target field. However within that Specify Field configuration there is an additional Specify button next to the Repetition number (see image 2). It looks like you clicked on that Specify button when you shouldn't have. Please reset the Repetition to 1.

                                     

                                    Screen Shot 2016-11-14 at 10.12.35 AM.png

                                    Screen Shot 2016-11-14 at 10.11.58 AM.png

                                     

                                    Additionally, when you click on the Specify button next to Calculated Result enter only your variable name. (Do not enter: Table::FieldName = $VariableName as that will produce a boolean calculation.)

                                    1 of 1 people found this helpful
                                    1 2 Previous Next