10 Replies Latest reply on Apr 25, 2017 6:19 PM by philmodjunk

    wrong script runs

    sdurante

      I have two scripts that I run in succession on individual records when needed, "process 1" and "process two." Process two acts on the results of process 1.

      Process 1 always works. Process two works the second time I use it after the first run fails. And this is how it fails: the script debugger says I am running process 1 again --although it's from the a different button for process 1 and the same button/trigger I unsuccessfully used the first time I ran process two--and sure enough the results are there: a repeat of process 1. The next time I run process two, it actually runs and works on the second results of process 1.

       

      I tried recovering the file but it didn't help. Are my scripts/buttons crossed? Has anyone ever seen this? I tried rewriting the scripts from scratch and that did not help. Am I missing something. I didn't post the scripts because this seems generic to me.

        • 1. Re: wrong script runs
          ch0c0halic

          Let me assure you the behavior you describe is 100% not expected or desired in any way.

          (So if it was "Generic" don't you think a lot of people would be writing about it?)

           

          Best to post your scripts, I recommend printing them to PDF documents and adding to the conversation on-line.

          • 2. Re: wrong script runs
            sdurante

            And here's another twist. If the two scripts are run and then undone even after failure of process two, they will work flawlessly on the record the next times thereafter. It only fails the first time for each record attempted.

            • 3. Re: wrong script runs
              philmodjunk

              For some reason, you posted the question twice. The other link is here: Wrong script runs

               

              You can delete that one to avoid confusion.

               

              But you really need to post those two scripts so that we can see exactly what you have. How the scripts are performed, (button, script trigger, perform script step...) can also be significant so tell us that detail as well.

              • 4. Re: wrong script runs
                sdurante

                Is there a way to share pdfs?

                • 5. Re: wrong script runs
                  philmodjunk

                  You can use the advanced editor, but it's easier/better to:

                   

                  Upload a screen shot from the scripts workspace

                   

                  or

                   

                  Copy the script steps from the PDF as text and paste it here.

                   

                  If you have FileMaker Advanced, you can even copy/paste a script as text from a DDR.

                  • 6. Re: wrong script runs
                    sdurante

                    On the page is a portal that is to be populated with data from two records via these scripts. There are six fields that need to be populated, three from each of two records.

                    Script one imports three fields from the current record into the portal's table.

                    That works predictably.

                    The user then opens another portal in a popover to select the record to use to populate the three remaining fields in the "portal record" created in step one.

                    Script two is triggered by a button on the appropriate portal row showing the record that has the fields that need importing.

                    The result I get is: step one works. The portal table gets the data and displays it in the portal.

                    Step two is to find the record that has the data for the three remaining portal fields. That is located and selected via a portal.
                    Step three: From the portal, the user runs script two importing the remaining wanted data into the portal record he created in script one. The first time the script two button, "Link," is pressed it triggers script one(!) according to the debugger and creates an exact duplicate of the first portal entry even though that data is not part of script two. If I then repeat script two, the proper script runs and imports the data into the second portal record that was created and I'm left with a partially populated first portal record that I must delete ("Break Link" button).

                     

                    The page looks like this:

                     

                    "Make this member Partner 1" works. It runs script one. The "Break Link"(delete portal row) and "Go" buttons in the portal work fine too.

                    Here is script one:

                     

                    The "Find and Link Partner 2" button is a portal button. The portal looks like this:

                    Pressing the "Link" button on the portal row runs script two.

                     

                    Here is script two:

                    The refresh and pause were my last- ditch attempts

                    • 7. Re: wrong script runs
                      brucewilson

                      It sounds like a script trigger is in place.

                      Use the script debugger to find out exactly WHEN process 1 starts again.

                      It could be when you "go to layout", in which case you look at script triggers in Layout setup.

                      • 8. Re: wrong script runs
                        philmodjunk

                        I agree. This smells like a script trigger being tripped by either user actions or by the script. The debugger, however should show you the name of that trigger when it's tripped.

                         

                        There also are a number of issues with your script, from methods that are simply more complicated than necessary to a go to related records step that does not appear to specify the correct layout--but I cannot be sure that this is actually the case.

                         

                        What we don't know are the relationships nor the names of the table occurrences on which the layout and the portals are based and that's needed to understand context while reading these scripts. But none of that would explain why the wrong script is performed and that brings me back to the suspicion that a script trigger is being tripped.

                        • 9. Re: wrong script runs
                          sdurante

                          Try to wrap your head around this; I can't.

                          I went back in just now and everything works. I tested it thoroughly.

                          Since my last post, I had changed NOTHING.

                           

                          I had created script two by duplicating script one, renaming it, and editing the steps. It occurred to me that perhaps FM still connected it somehow to script one. I had made new buttons  and fresh scripts with the desired steps and it still didn't work. That's when I decided to post my problem to the community.

                          Now, some hours later, after changing nothing, it works. The debugger reports that the proper scripts are running when called up.

                           

                          This is not comforting, but I am happy it works now.

                          • 10. Re: wrong script runs
                            philmodjunk

                            Still might be due to a script trigger. Triggers can be tripped by a change in focus. Your file might have the focus on a different part of your layout and thus, the trigger is not tripped this time.

                             

                            But another possibility: might you have been testing without saving the changes to your duplicated script?