AnsweredAssumed Answered

Geodatabase Sync works for upload, but not download

Question asked by jcha129 on Sep 26, 2018

Hi 

 

    I am try to sync my local geodatabase file to server and pull any change from server to my local geodatabase.

My code is working when i set syncDirection to SyncDirectionUpload on layerOptions.

 layerOptions: [
            SyncLayerOption {
                layerId: "0"
                syncDirection: Enums.SyncDirectionUpload
            },

 

However when i set the syncDirection to SyncDirectionBidirectional or SyncDirectionDownload

I received a sync error, 

 

"Job failed. Job error 22 User defined failure. Error while handling get server sync job status. Job error 500 Failed to synchronize"

 

 

I am loading a geodatabase using a file path, after grodatabase obj is created and loaded, i pass it to the syncTask.

 

The code look like

function loadDatabaseAndSync(gdbFilePath){
  offlineGdb = ArcGISRuntimeEnvironment.createObject("Geodatabase", {path: gdbFilePath})
  var loadingJob = offlineGdb.loadStatusChanged.connect(startToSyncAfterDatabaseLoad);
  offlineGdb.load();
}
    function startToSyncAfterDatabaseLoad () {
            if (offlineGdb.loadStatus === Enums.LoadStatusLoaded) {
                console.log("Database loaded")
                geodatabaseSyncTask.executeSync()
                offlineGdb.loadStatusChanged.disconnect(startToSyncAfterDatabaseLoad);
            }
        }
function executeSync(){
            console.log("executeSync running" )
            // execute the asynchronous task and obtain the job
            
syncJob = geodatabaseSyncTask.syncGeodatabase(syncParameters, offlineGdb)
            // check if the job is valid
            if (syncJob) {
                busyControl.visible = true
                // connect to the job's status changed signal to know once it is done
                syncJob.jobStatusChanged.connect(updateSyncJobStatus)
                // start the job
                syncJob.start()
            } else {
                // a valid job was not obtained, so show an error
                console.log("Job not obtained")}
        }
SyncGeodatabaseParameters {
        id: syncParameters
        layerOptions: [
            SyncLayerOption {
                layerId: "0"
                syncDirection: Enums.SyncDirectionDownload
            },
            SyncLayerOption {
                layerId: "1"
                syncDirection: Enums.SyncDirectionDownload
            },
            SyncLayerOption {
                layerId: "2"
                syncDirection: Enums.SyncDirectionDownload
            },
            SyncLayerOption {
                layerId: "3"
                syncDirection: Enums.SyncDirectionDownload
            }
        ]
    }

Outcomes