3 Replies Latest reply on Apr 6, 2016 4:30 PM by macwombat

    Getting an error 101 working through the iOS sync white paper

    Razor

      I'm working my way through the white paper published by FM on iOS syncing, https://community.filemaker.com/docs/DOC-3838

       

      For those familiar with the paper I'm currently working on the Run Script part of the operation.  This is where a connector file is exported from a container field and made available to the deployed device.  The original white paper code follows;

       

      # Assumes that the connector file is stored in a field called gContainer in a System table in the deployed file, the following script steps in the deployed file will export and open the connector file:

      Set Field [System::gPivot; “”]
      Set Field [SyncLog::Action; “Export and open connector file”] Commit Records/Requests [Skip data entry validation; No dialog]

      Set Variable [$path; Value: "file:" & Get(DocumentsPath) & "SyncConnector.fmp12"]

      Export Field Contents [System::gContainer; “$path” ]
      Set Variable [$e1; Value: Get(LastError)]

      If [$e1 = 0]

        Open URL ["FMP://~/SyncConnector.fmp12?script=Run Sync"; No dialog]

        Set Variable [$e2; Value: Get(LastError)]

      End If

      And this is the original version of the Run Sync script;

       

      Go to Layout [“SyncCentral” (“ConnectorSystem”)]
      Set Field [ConnectorSystem::gPivot; “”]
      Set Field [DeployedSyncLog::Action; “Retrieve timestamp values for sync run”]
      Set Variable [$SyncTimeStamp; Value: DeployedSystem::gSyncTimeStamp]
      Set Variable [$CurrentSyncTimeStamp; Value: Get(CurrentTimeStamp)]
      Set Field [DeployedSyncLog::Result; “Sync start timestamp stored as a variable”] Commit Records/Requests [Skip data entry validation; No dialog]
      Set Field [ConnectorSystem::gPivot; “”]
      Set Field [HostedSyncLog::Action; "Sync commenced by " & DeployedSystem::gUserID & " at " & $CurrentSyncTimeStamp]
      Set Variable [$HostSyncLogID; Value: ConnectorSystem::gPivot]
      Commit Records/Requests [Skip data entry validation; No dialog]

       

      My code is working up to the point where it tries to write back to the DeployedSyncLog table.  I’m receiving a 101 error when executing this command;

       

      Set Field [DeployedSyncLog::Action; “Retrieve timestamp values for sync run”]

      Screen Shot 2016-04-05 at 6.17.00 PM.png

      I’m not sure if there is something missing in the white paper, or if I’m doing something wrong but to get around this error I made the following changes in red;

       

      Set Field [System::gPivot; “”]
      Set Field [SyncLog::Action; “Export and open connector file”] Commit Records/Requests [Skip data entry validation; No dialog]

      Set Variable [$path; Value: "file:" & Get(DocumentsPath) & "SyncConnector.fmp12"]

      Export Field Contents [System::gContainer; “$path” ]
      Set Variable [$e1; Value: Get(LastError)]

      New Record/Request

      Set Variable [$paramID ; Value: SYNCLOG::ID]

      If [$e1 = 0]

        Open URL ["FMP://~/SyncConnector.fmp12?script=Run Sync&param="&$paramID]

        Set Variable [$e2; Value: Get(LastError)]

      End If

       

      I then had to make the following change in the Run Sync script;

       

      Go to Layout [“SyncCentral” (“ConnectorSystem”)]
      Set Field [ConnectorSystem::gPivot;
      Get ( ScriptParameter )]
      Set Field [DeployedSyncLog::Action; “Retrieve timestamp values for sync run”]

       

      With these changes I am now able to set the field in my DeployedSyncLog to Retrieve timestamp values for sync run.

       

      By the way these are my TO’s in the SyncConnector file;

      Screen Shot 2016-04-06 at 12.10.31 PM.png

       

      To me this seems like a glaring omission in the original example.  Obviously the other possibility is that I did something wrong trying to follow the example in the paper.  I’m still relatively new to FM, but I don’t see how else to make the example work.

       

      Is what I did the right way to fix this?

        • 1. Re: Getting an error 101 working through the iOS sync white paper
          rgordon

          Double check to see if gsynctimestamp  is a global field and the deployed system table might need to have at least one record.

          • 2. Re: Getting an error 101 working through the iOS sync white paper
            Razor

            Thanks rgordon, gSyncTimeStamp is a global in my table, and there is one record in the deployed System table.  It contains the connector file. 

             

            The connector file does launch and the script in the connector file starts to run, however without my additions/changes it cannot write back to the DeployedSyncLog.

             

            When creating a new record in a table through a script don't you always have to send a New Record/Request command before you can start writing a new record?  The original example is missing that command.

            • 3. Re: Getting an error 101 working through the iOS sync white paper
              macwombat

              Razor wrote:

               

              When creating a new record in a table through a script don't you always have to send a New Record/Request command before you can start writing a new record?  The original example is missing that command.

               

              Can't comment on the whole thread but in answer to this question - no.  I don't know how your relationships are set up but if you have "Allow creation of records in this table via this relationship" then you can start "writing a new record" via a set field script step.  Look up FileMaker Magic Key in google and you'll find plenty of articles which describe this process.  I'm assuming from looking at the script in your screenshot that it is using magic key to create new records.