10 Replies Latest reply on Jan 12, 2016 1:57 PM by BruceRobertson

    Using the "Set Variable" script step

    Mike6074

      I am trying to create a script that will assign a value from a Set Variable script step to a defined field.  However, it only seems to work if I include a "New Record" script step before  assigning the value. Does anyone know why?

        • 1. Re: Using the "Set Variable" script step
          BruceRobertson

          Generally it does not help to say "this isn't working" without explaining what "this" is.

           

          Can you show us your complete script?

          • 2. Re: Using the "Set Variable" script step
            Mike6074

            Bruce,

             

            Thank you for responding.  I apologize if I was vague, but I am new to the forum.  At any rate, I hope this is a better explanation.

             

            Script that somewhat works is as follows:

                                                         Set Variable

                                                         New/Record/Request

                                                         Set Field

                                                         Exit Script

            While this strip works, it obviously creates a new record (which I don’t want) and then places the $Output value into the Output field.  It does not work if I remove the New Record/Request step, i.e., no value is placed int the Output field.

             

            Some additional info:

             

            >If I create a Script Trigger (i.e., OnObjectExit), the Script then enters an endless loop unless I change Exit Script to Halt Script.

            Also, it only works if I define Output  as a calculate number and set it equal to $Output, otherwise no value is placed in Output.

             

            While I am not an expert Filemaker user, I am not a new user either.  I have read the available documentation regarding Set Variable and Script Triggers including the examples.  It looks pretty straight-forward, but I am obviously missing something.  I surely appreciate your help.

             

            Michael.

            • 3. Re: Using the "Set Variable" script step
              BruceRobertson

              That really isn't anywhere near to sufficient detail.

              It will be better if you attach your file; or an example file that you have built to demonstrate the problem.

              • 4. Re: Using the "Set Variable" script step
                User24245

                Hi,

                 

                The attached script does work on my computer. So, Please re-check your script again.

                 

                Thanks.

                Screen Shot 2016-01-12 at 11.42.50.png

                • 5. Re: Using the "Set Variable" script step
                  Mike6074

                  Bruce,

                   

                  I appreciate your patience.  What I sent is the exact script, but I understand - it doesn’t show the underlying solution that calls the script.  Before trying to incorporate the script into the solution that I intended to use it for, I created a simple “test file” which I am attaching.  I hope it helps you to help me.  At the risk of stretching your patience, if what I am sending does not work for you, the test file is very simple consisting of only two fields:  I call them Input and Output.  The Input field is manually entered and then is used to create the $Output variable, which is then intended to be transferred to the Output field using the script.

                   

                  Again, thank you.

                   

                  Michael

                  • 6. Re: Using the "Set Variable" script step
                    BruceRobertson

                    No you did not send the exact script. Print the script to PDF and attach it. Also: no file attached so far.

                    • 7. Re: Using the "Set Variable" script step
                      Mike6074

                      Bruce,

                       

                      Thanks for trying to help, but I am obviously wasting your time.  I will do more research and, when more knowledgeable, perhaps get back to you.

                       

                      Michael

                      • 8. Re: Using the "Set Variable" script step
                        jbante

                        Do you have an empty found set before you use the New Record/Request script step? Is the field you are setting stored globally or not? If the Set Field step is setting a local field, you have to have an active record, which doesn't exist if your script starts with an empty found set.

                         

                        What's your purpose in setting the field? Why don't you want the data in the variable stored to a record, even temporarily? You haven't told us, so I'm guessing that you want to set a field for the purpose of displaying the contents of the variable to end users. If so, display a merge variable on a layout instead of a field. You may have to tinker with refreshing to get it to work as expected.

                        • 9. Re: Using the "Set Variable" script step
                          BruceRobertson

                          Why don't you just do what you said you were going to do?

                          ATTACH A FILE?

                          And - when discussing scripts, don't post generilizations and vague it's sort of like this step lists.

                          Post ACTUAL scripts?

                          Note that to attach a file, you need to select "Use Advanced Editor" and then use the ATTACH option at the bottom right once you are there.

                          You are going to run into the same problems in any forum on any subject if you cannot actually provide real meaningful detail.