QML Javascript get Attachments

05-14-2020 09:06 PM
New Contributor

Hi Erwin,

I recently took the zoom class in appStudio. I was able to figure out quite a bit from the documentation, but I'm having a hard time with getting attachment information from the feature qml object.  I'm trying to select a feature qml object from a featureLayer qml object and get the attachment info.  After the Selection, whenever I do feature.attachments.count  it returns 0 and I know that there are attachments.  I know I can return the geometry of the feature and attributes, but having a hard time with attachments. It doesn't seem like the attachments QML List is asynchronous or that I need to do a fetch of any kind. I looked at the edit Attachment example on GitHub but for some reason I can't seem to replicate the example.  I feel like it's something easy I'm missing.  Thanks for any assistance.

James W.

0 Kudos
2 Replies
Esri Regular Contributor


How did you get the attachment? Can you show us some code snippet? 

Are you using this method from ArcGIS Runtime SDK for QtAttachmentListModel QML Type | ArcGIS for Developers ?

Remember this is an asynchronous call, so we need check the status of the fetchAttachment operation, there is a chance that it is not completed yet, AttachmentListModel QML Type | ArcGIS for Developers 

Thank you,


0 Kudos
New Contributor

Erwin thanks for getting back to me. I think I figured what my issue was. I wasn't letting the async finish before doing the count. This is my code snippet that gets me the attachment info, it seems.



console.log("the task has completed")


var firstAttachment = feature.attachments.get(0)


}else if(feature.attachments.fetchAttachmentsStatus!==Enums.TaskStatusCompleted){

console.log("task has not completed")





0 Kudos