Select to view content in your preferred language

Offline Geodatabase Attachments

430
1
03-28-2019 01:20 PM
LaurynasGedminas2
Regular Contributor

I have downloaded the Geodatabase thru GeodatabaseSyncTask. with 'returnAttachments: true' as parameter.

I am using click>Identify>Select features on the map, then download attachment thru this code,

code below get attachments from online feature service, geodatabase feature service returns nothing:

onSelectFeaturesStatusChanged: {
    if (selectFeaturesStatus === Enums.TaskStatusCompleted) {
        if (!selectFeaturesResult.iterator.hasNext)
            return;
        selectedFeature = selectFeaturesResult.iterator.next();
        attachmentListModel = selectedFeature.attachments;
        attachmentListModel.fetchAttachmentsStatusChanged.connect(function() {
            if(attachmentListModel.fetchAttachmentsStatus === Enums.TaskStatusCompleted){
                console.log("loaded");
                console.log(attachmentListModel.count);
                attachmentListModel.forEach(function(element, index, array) {
                    element.fetchDataStatusChanged.connect(function(){
                        if(element.fetchDataStatus===Enums.TaskStatusCompleted){
                          console.log(element.attachmentUrl);
                        }
                    });
                    element.fetchData();
                });
            }
        });
    }
}

					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
0 Kudos
1 Reply
LukeSmallwood
Esri Contributor

Hi Laurynas,

There are a couple of things which may be worth considering with your example code:

There is no explicit call to fetchAttachments on the attachmentListModel that I can see. That's probably ok, as I think these should be set to autoFetchAttachments - but worth double-checking.

The second possibility is that, because your geodatabase is offline, the attachments are already "fetched" (e.g. no network request needs to be made). If that is the case, your example would never receive the attachmentListModel.fetchAttachmentsStatusChanged signal (because the status is already complete). If that is the case, you should be able to update your code to check the status first and execute the same logic that you have in your connect statement.

I hope that helps,

Luke

0 Kudos