on 02-05-2019 11:17 AM
hello,
I'm trying to download an attachment using UploadCollection. I get this error with the code I'm currently trying :
Unable to get property 'getProperty' of undefined or null reference
I have implemented GET_STREAM method in the backend using this blog as a reference :
https://blogs.sap.com/2018/09/18/object-services-attachments-using-uploadcollection/
OData
XML
<UploadCollection id="UploadCollection" noDataText="NO Attachments" uploadEnabled="false">
</UploadCollection>
JS
var that = this;
var otxtIONo = that.getView().byId("txtIONo");
var IONum = otxtIONo.getValue();
var oUploadCollection = that.getView().byId("UploadCollection");
var sServiceUrl = "/sap/opu/odata/AAG362/FI_INTERNAL_ORDER_SRV";
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
oModel.setUseBatch(false);
var Attachment = "/InternalOrderSet('" + IONum + "')/AttachmentSet";
oModel.read(Attachment, {
success: function (oData, response) {
if (oData.results !== "undefined" || oData.results !== null) {
// oUploadCollection.setModel(oJSONModel, "Attachment");
var surl = sServiceUrl + "/AttachmentSet(AttachmentGuid ='" + oData.results[0].AttachmentGuid + "')/$value";
console.log(surl);
var item = new sap.m.UploadCollectionItem({
fileName: oData.results[0].Description,
mimeType: oData.results[0].MimeType,
url: surl,
documentId: oData.results[0].InternalOrder,
// fileSize: oData.results[0].FileSize,
visibleDelete: false,
visibleEdit: false
});
oUploadCollection.addItem(item);
}
},
error: function (oError) {
sap.m.MessageBox.show(oError, sap.m.MessageBox.Icon.ERROR, "Error");
}
});
please help
thanking you in advance
Siddharth
hello,
I figured out the download of it, I used a different XML Component (List) to unable download.
xml
<List id="UploadCollection" items="{attDoc>/docData}" inset="true" showSeparators="None">
<items>
<StandardListItem id="UploadCollectionItem" press="docDownload" type="Navigation" iconInset="false"
title="{parts : [{path : 'attDoc>Description'},{path : 'attDoc>MimeType'}], formatter : 'ui.s2p.mm.purchorder.approve.util.Conversions.formatAttachmentDesc'}"
icon="{parts : [{path : 'attDoc>MimeType'}], formatter : 'ui.s2p.mm.purchorder.approve.util.Conversions.formatAttachmentIcon'}"
description="{parts : [{path : 'attDoc>FileSize'}], formatter : 'ui.s2p.mm.purchorder.approve.util.Conversions.formatAttachmentSize'}"></StandardListItem>
</items>
</List>
js
//Call this service on press
<SERVICEURL>/AttachmentSet(AttachmentGuid='<AttachmentGuidNo>',FileName='<FileName>')/$value
thanks
Siddharth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.