11 Replies Latest reply on Nov 28, 2012 2:12 PM by brian.curran

    What is a 'Branch'?

    brian.curran

      Title

      What is a 'Branch'?

      Post

           I'm integrating GoZync into my database and have followed every instructional step along the way (some of them several times!) but there's one that has very little documentation and that's adding 'Branches'

            

                  
      1.                

        #------------------------------------------------------------------------------
                            #Are we already on the layout whose records you want to check? #------------------------------------------------------------------------------
                            #if not, go to layout

        Freeze Window
                            Go to Layout
        [ “Contract” (Site) ]
        #
                            #
                            #------------------------------------------------------------------------------ #Find any unsent records #------------------------------------------------------------------------------

        Set Error Capture [ On ]
        Enter Find Mode [ ]
        Set Field By Name [ Get ( LayoutTableName ) & "::gz_Send"; 1 ] Perform Find [ ]
        If [ Get ( LastError ) = 0 and Get ( FoundCount ) > 0 ]

                       

        Set Variable [ $unsentRecords; Value:"Yes" ] End If

                       

        #
                            #
                            #------------------------------------------------------------------------------
                            #Add a branch / section here for each table you'd like to check for unsent records.

                       

        #------------------------------------------------------------------------------ 

                  
      2.      

           I'm not sure what a branch is but without it, my data won't sync to my iPad. The documentation states that for every layout I want to sync, a branch for that layout must be added to the branch/section.

           Are 'branches' a FM thing or a term that SeedCode uses? Either way, I need help, again :)

        • 1. Re: What is a 'Branch'?
          philmodjunk

               They want you to add code with Go TO Layout steps and If steps that check each table for unsent records, The code immediately above can be duplicated and used to for each additional layout. It might even be possible to set up a loop for this where you loop through a set of layouts with some database designs.

               I can't tell from the code posted how this will affect the use of $UnsentRecords in your script, however.

          • 2. Re: What is a 'Branch'?
            brian.curran

                 Thanks Phil, the SeedCode guys are online now and have said the same things as you, to duplicate the exesting Go To and If script steps.

                 The script checks to see if there any 'updated' records before downloading a new version of the app. This is to prevent the update overwriting  the data that has yet to be sent upstream to the host file.

                 I don't expect you to be familiar with the GoZync stuff unless you have worked with a copy of it before but it's now throwing an error:

            Error: -2
            Missing the "LayoutName"
            Parameter
            Script: "Get Fields { FileName }

            (LayoutName; LayoutTableName)".

                  

                 Thanks
                 Brian.

            • 3. Re: What is a 'Branch'?
              philmodjunk

                   That would seem a self explanatory error message and I highly recommend that you continue your dialog with SeedCode.

              • 4. Re: What is a 'Branch'?
                brian.curran

                     The SeedCode forums are like a ghost town compared to here so it's really frustrating having to sit back and wait for a reply especially on a Friday evening. Thanks for all your help Phil, as always it's very much appreciated...

                • 5. Re: What is a 'Branch'?
                  brian.curran

                       Not much of a reply from SeedCode, it looks like I now have to sit and stew until Monday evening to await details of their proposed Support package! GoZync is definitely not a plug and go type add on for anyone with less than expert skill level in FM...

                       Anyway, I can't just sit here and wait for them to hopefully get back to me as this setup has been ongoing for over a week now. I think I've found where the error is kicking off, now I need to know how to trace this to a possible fix...

                  • 6. Re: What is a 'Branch'?
                    Sorbsbuster

                         You would need to back up a bit and see where the $Error variable is being set, to narrow down which part is going wrong.  To clarify, have you copied/duplicated into your script this full section, for every layout you want to check?  Presumably, of course, you don't have to check every actual layout, just one layout per table.  (And do you have to have on that layout all the fields that could be synched?  Some sync'ing programs do need that.)

                         So, you need to start with these script steps:

                                
                    1.                

                      #------------------------------------------------------------------------------
                                          #Are we already on the layout whose records you want to check? #------------------------------------------------------------------------------
                                          #if not, go to layout

                      Freeze Window
                                          Go to Layout
                      [“Contract” (Site)]
                      #
                                          #
                                          #------------------------------------------------------------------------------ #Find any unsent records #------------------------------------------------------------------------------

                      Set Error Capture[On]
                      Enter Find Mode[ ]
                      Set Field By Name[Get ( LayoutTableName ) & "::gz_Send"; 1]Perform Find[ ]
                      If[Get ( LastError ) = 0 and Get ( FoundCount ) > 0]

                                     

                      Set Variable[$unsentRecords; Value:"Yes"]End If

                                     

                      #
                                          #
                                          #------------------------------------------------------------------------------
                                          #Add a branch / section here for each table you'd like to check for unsent records.

                                     

                      #------------------------------------------------------------------------------

                                
                    2.           
                    3.                

                                          And then replace the red lines with say:

                                
                    4.           
                    5.                
                                                 
                      1.                               

                        #------------------------------------------------------------------------------
                                                           #Go to the next layout  to check

                        #------------------------------------------------------------------------------

                                                 
                      2.                          
                      3.                               

                        #if not, go to layout
                        Freeze Window
                                                           Go to Layout
                        [“Customer details” (Contacts) ] // for example
                        #
                                                           #
                                                           #------------------------------------------------------------------------------ #Find any unsent records #------------------------------------------------------------------------------

                        Set Error Capture[On]
                        Enter Find Mode[ ]
                        Set Field By Name[Get ( LayoutTableName ) & "::gz_Send"; 1]Perform Find[ ]
                        If[Get ( LastError ) = 0 and Get ( FoundCount ) > 0]

                                                      

                        Set Variable[$unsentRecords; Value:"Yes"]End If

                                                      

                        #
                                                           #
                                                           #------------------------------------------------------------------------------

                                                 
                      4.                     
                                
                    6.      

                         Perhaps you didn't duplicate all the steps correctly.  It should 'work' if you just leave the script as is - at least it shouldn't generate an error if their base code is correct.  It just won't sync the rest of the tables.  Might be worth trying it with the one table first.

                         Warning: I have never used GoZync....

                    • 7. Re: What is a 'Branch'?
                      brian.curran

                           Thanks, I tried looking for the $error variable but when the initial error pops up the script debugger is greyed out until I press the OK button and then it all resets itself unfortunately.

                           I duplicated the section above and checked it to ensure that I had included all layouts. That didn't work so I started from scratch again with the entire integration. Each layout was created and synced, all fine for the first 4 but the 5th one is a large multi-tabbed dashboard with 28 related TO's and it just fails every time.

                           A sync log shows:


                                11/11/2012 3:32:06 PM - Started

                           -------------------------

                            Split     Total

                           0:00:00 - 0:00:00 - Mobile file connected

                           0:00:01 - 0:00:01 - Preparing & sending 0 records: Site

                           0:00:00 - 0:00:01 - Completed 0 records: Site

                           0:00:00 - 0:00:01 - Processing Inbox for Device "DDD95A92C76203E14982FBB52B1E7180"

                           0:00:01 - 0:00:02 - No inbox records to process

                           0:00:00 - 0:00:02 - Pulling TOs

                           0:00:02 - 0:00:04 - Site

                           0:00:03 - 0:00:07 - Starting record search on Layout "Site"

                           0:04:07 - 0:04:14 - Preparing to send Site to outbox: starting id loop

                           0:00:00 - 0:04:14 - FLM is on

                           0:00:00 - 0:04:14 - ID collection done

                           0:00:00 - 0:04:14 - Serializing 197 Site records

                           0:10:33 - 0:14:47 - Completed 28 Site records.

                           0:00:00 - 0:14:47 - Add attachments

                           0:02:05 - 0:16:52 - Add attachments done

                           0:00:08 - 0:17:00 - Done

                           0:00:44 - 0:17:44 - Closing GoZyncHosted

                           The two entries in red are interesting as there are 197 site records but only 28 of them sync successfully...

                      • 8. Re: What is a 'Branch'?
                        Sorbsbuster

                             I thought you might be able to literally look back through the script steps and see where the $Error was being set.

                             Is there a possibility that you are meant to create a layout specifically for synchronisation, for each table to be synchronised, based on the table you intend, with only those fields on the layout that need to be synchronised?  In other words, you would never have related fields, as they would be synchronised when their own table was targeted.

                             To me, it's interesting ('significant') that you can make 4 copies of the script steps work correctly, but the 5th fails.  That would suggest the failure is specific to the layout and its contents, obviously.

                             At this stage I have to admit defeat and say I have never used GoZync, so it's over to its parents for me...

                        • 9. Re: What is a 'Branch'?
                          brian.curran

                               Thanks for your thoughts, I'll have another look to see where the Set Variable ($error) script is to see if that gives me any more of a clue.

                               Regarding the 5th layout, yes it must be something to do with the layout itself but I'm stumped and don't really understand the method that it works through, hopefully SeedCode will be able to have a look at it sometime tomorrow...

                                

                          • 10. Re: What is a 'Branch'?
                            Sorbsbuster

                                 What happens if you:

                                 - duplicate the layout
                                 - remove all the related fields
                                 - change the destination layout in the script to be that one
                                 - run the sync

                                 If it works then the theory might hold water.  Presumably the removed related data would be sync'ed when you moved to their table.

                            • 11. Re: What is a 'Branch'?
                              brian.curran

                                   Thanks for your help Sorbsbuster, I tried your steps above but screwed it all up unfortunately. Seedcode support found the problem after reviewing my files...