QML Javascript get Attachments

293
2
05-14-2020 09:06 PM
JamesWallace1
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
ErwinSoekianto
Esri Regular Contributor

James,

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,

Erwin

0 Kudos
JamesWallace1
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.

feature.attachments.fetchAttachmentsStatusChanged.connect(function(){

if(feature.attachments.fetchAttachmentsStatus===Enums.TaskStatusCompleted){

console.log("the task has completed")

console.log(feature.attachments.count)

var firstAttachment = feature.attachments.get(0)

console.log(firstAttachment.name)

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

console.log("task has not completed")

}

})?

Thanks,

James

0 Kudos