5 Replies Latest reply on Aug 6, 2013 9:46 AM by philmodjunk

    Trouble with script on IWP.



      Trouble with script on IWP.


           I have a script that works if used on Filemaker Go or Filemaker Pro 12, but does not work on IWP.  The script is very long.  Below I have screenshot of a very small portion of it.  The first 3 "IF" statements are in place so the communication cannot be saved unless the "Communication," "Entered By," and "Hall" have all been filled out.  The Hall designates the work area. The script is set to go to the "Employee" table and find if there is a "yes" for the area that communication is for.  The employee table has the person's name and  a "yes" or "no" for each work area indicating if they do or don't  work in that area.  So if the work area is "Hickory."  The script will go to Employee table, search for everyone with a "yes" by their name by "Hickory" and then sort the found set in alphabetical order.  The names are then one by one copied and pasted into the communication for labels so that the workers of that area can sign next to it indicating they have read the info.  Like I said this works for iOS and and Filemaker pro 12, just not IWP.   

           The total script with the "IF" statements is about 1300 steps, is it the lenght of the script or am a missing something.  All of the steps are allowed if I apply the Instant Web Publishing filter at the bottom of the scipt when writing it.  Or if you can recommend a different way to get all these names over.  I want the names to be set when the communication is written, so that it stays and we can look back.


        • 1. Re: Trouble with script on IWP.

               This may clear it up for you.  The names that are copied and pasted become the labels.

          • 2. Re: Trouble with script on IWP.

                 I don't think this is the problem, but your script does a lot of copy/paste actions. It's better to use set varaible/set field in place of copy/paste. Copying data to the clipboard overwrites any data that the user may have previously copied to the clipboard and the field copied from and pasted to must both be physically present and accessible on your layout or they will fail to work. Using Set Variable/Set field avoids those issues.

                 two things you might check is that I see a lot of go to layout steps. Make sure that each layout is classic themed (if you are using FileMaker 12) and check to see if this script might be tripping any script triggers with the layout changes. Quite a few different triggers can be tripped when you change layouts and you might be tripping another script here that has an issue with IWP.

            • 3. Re: Trouble with script on IWP.

                   Forgive me for my ignorance but how do I set that field using the variable that I just made with Set Variable?

              • 4. Re: Trouble with script on IWP.

                     I checked each layout is classic and my layouts don't have scripts attached to them opening etc.  All of my scripts run based a button being pressed.

                • 5. Re: Trouble with script on IWP.

                       In place of copy, use:

                       Set Variable [$VariableNameHere ; value: YourTable::FieldToCopyHere ]

                       In place of paste use:

                       Set FIeld [YourTable::FieldtoPasteIntoHere ; $VariableNameHere ]

                       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.

                       With regards to your script, I suggest some tests to narrow down your focus to just a part of 1300 step script.

                       Define a new table, ScriptLog with a single field: Milestone.

                       Add the following code to numerous points throughout your script:

                       Go to Layout ["ScriptLog" (ScriptLog) ]
                       New Record/Request
                       Set Field [ScriptLog::Milestone ; 1 ]
                       Go to Layout [original layout]

                       Just make the value in the set field a different number, 1, 2, 3, 4 etc.

                       Then run your script via a web browser then use FileMaker pro to check the records produced in ScriptLog. If you see records numbered 1, 2, 3 but no other records created, then the problem is occurring between the set field step with 3 and the set field step with 4.