8 Replies Latest reply on Aug 30, 2014 7:58 PM by ariley

    Problem with SetField

    bigtom

      For all the usual reasons I have a robot client running label print jobs for iPad users.

       

      The iPad script sets a flag in a print table that the robot FMP client checks for. It also sets a field for the language the label needs to be printed in.

       

      The robot does fine and finds the flags and prints the labels and such. The issue I am having is a script step to set the language value does not alwasy work. I have tried SetField, SetFieldByName, GoToField and insert, Replace contents, and few others. I tried setting the value directly from the flag value and setting a variable the setting the language by variable.

       

      I watch the data viewer and the language field is set at 1. I pass in (by field set on the layout) the language flag of 2. I see the flag value and the $lang variable set to 2 in the data viewer. When the script step to set the language field runs it sometimes does not change to 2 and remains 1 and prints the incorrect language. Pressing the print button on the iPad a second time seems to set it correctly, but something as simple as SetField should always be working and quickly. If $lang = 2 and There is a step to SetField [language; $lang] then the field should be set to 2 and not 1.

       

      Also tried commiting records and refreshing windows at a number of points in the scripts. No help there. The language is run by a virtual list. I am thinking this has somethign to do with the speed of the script. When I run through it step by step in the script debugger it never fails. Running normally has problems. I tried pauses in the scripts but that did not help either. Tried running the robot script at long intervals 5+ seconds and still no change.

       

      The selected language field is in a related table to the record being printed and the field is on the layout.

       

      If FMGo had more control over printing in general this would not be a problem. Currently telling users to print a second label if the wrong language comes out.

       

      Any ideas on how to get this working better? My next step to test is a global variable but this is a problem when multiple print jobs with different languages are processing at the same time.

        • 1. Re: Problem with SetField
          ariley

          When I see issues like this, I put in a pause. Sometimes that helps.

           

          Or store the chosen language in a global text field then take it from there.

           

          There has to be something messing with it.

           

          Best regards,

           

          agnes b. riley

          filemaker and web development

          zeroblue

          download vCard

           

          TWO-TIME MAD DOG AWARD WINNER

          FileMaker Certified in 10 and 11 • Member, FileMaker Business Alliance

          T: 877 917-9079 . C: 917-660-7221

          Store | Blog | Facebook | Twitter | LinkedIn

          • 2. Re: Problem with SetField
            keywords

            A small trap with Set Field is that it does not, of itself, commit. You can easily see this if you run a script where the very last step is Set Field—after the script completes the cursor will still be in the field that was set. My first thought was that you needed to insert a step immediately after the Set Field ( language ) to address this, either Commit or alternatively Set Field () with no field specified is a scripted "click outside all fields" step. Since you say you have already thought of this, perhaps a pause will fix it, as suggsted by Agnes. It would also be worth checking the the language field is unindexed, or if it must be indexed that the index is reset. That last may be why a pause works.

            • 3. Re: Problem with SetField
              steve_ssh

              Hello Tom,

               

              Given what you described with watching the target language field value not update in the data viewer, this possibility seems like something of a long shot...

               

              That said, perhaps I didn't understand your post correctly, in which case:

               

              Something that you might wish to consider:

               

                Is the language field proper to the main TO context from which you are printing?

               

              If not:

               

              If the language field is in a TO which is at least one hop away from your print context TO, and moreover, if the TO with the records holding the localized text is yet another hop away, then I'd consider the possibility that you need to provide FM with a nudge to ensure that your are not displaying stale cached data.  This could be accomplished with either a relationship nudge (per: http://www.teamdf.com/weetbicks/42/ditch-those-flush-caches-use-cartesian-join-instead ), or via a window refresh with the flush cache option enabled.

               

              i.e.

               

              [ BASE PRINT TO ]  ---<  [ SOME OTHER TO ]  ---< [ LOCALIZED TEXT ]

               

              Where, language is a field from the table underlying SOME OTHER TO  ( and not from the table underlying BASE PRINT TO ).

               

              If you have the above sort of arrangement, it is possible that the layout based on BASE PRINT TO could show "stale" data from LOCALIZED TEXT even if the language field has been updated and committed.

               

              If you do not have the above sort of relationship, then please ignore and excuse this post. 

               

               

               

               

              Regardless:

               

              Good luck and best wishes,

               

              -steve

              • 4. Re: Problem with SetField
                bigtom

                Steve, the TO with the main localized text flag is not related at all, my mistake, and that may be the issue. Current language changes open new window with the localized text flag TO and set language value by script and then updating the value list and back to the window that was in use. It is very fast even on the iPad over WAN, but I guess not being related is causing data update issue unless I use the script to go to the TO to set the value directly for the label print as well.

                 

                I have tried the refresh with flushing cache, but maybe that is taking too much time to update all the records. The cartesian join idea looks like it should work. I will give it a try.

                 

                Thanks

                • 5. Re: Problem with SetField
                  ariley

                  Is that a global field you’re trying to set? If yes, you don’t need it to be related. Otherwise it helps. Since you’re accessing it from the context of a layout.

                   

                  Best regards,

                   

                  agnes b. riley

                  filemaker and web development

                  zeroblue

                  download vCard

                   

                  TWO-TIME MAD DOG AWARD WINNER

                  FileMaker Certified in 10 and 11 • Member, FileMaker Business Alliance

                  T: 877 917-9079 . C: 917-660-7221

                  Store | Blog | Facebook | Twitter | LinkedIn

                  • 6. Re: Problem with SetField
                    bigtom

                    It is a global field.

                    • 7. Re: Problem with SetField
                      bigtom

                      Still had trouble so I started adding long pauses from the end toward the begining. Found the initial variable setting was getting a stale value. Without the long pauses it was impossible to see what was happening. A record commit and a .2 second pause before the set variable fixed it. Also added and IF to speed up printing by only updating the language if it is not the same as the current setting.

                       

                      Thanks for all the ideas.

                      • 8. Re: Problem with SetField
                        ariley

                        Told ya, pause is your friend.

                         

                        Glad you got it solved.

                         

                        Best regards,

                        Agnes Riley

                        www.zerobluetech.com

                        877 917-9079

                         

                        Sent from my iPhone