AnsweredAssumed Answered

Getting an error 101 working through the iOS sync white paper

Question asked by Razor on Apr 6, 2016
Latest reply on Apr 6, 2016 by macwombat

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?

Outcomes