cancel
Showing results for 
Search instead for 
Did you mean: 

SAP MDK - Creating an attachment entry using createAttachmentEntry function.

0 Kudos

Hi Experts,

I’m building an app with pages built dynamically in Rules, and that is connected to an OData service with Offline functionality enabled.

I have a page with an attachment control that can contain images already loaded in from the OData service.

The entityset that contains the image is a Media Entity (has the HasStream="true" attribute). In a rule I’m able to read the the entityset, download the media, verify if its local but I cant build the createAttachmentEntry to feed into the Attachment control value.

I went through the example and the documentation on both the attachment and the createAttachmentEntry and I couldn’t get it to work.

Here is the metadata of the Entity of the attachment: <E

<EntityType Name="MyOrderDocument" m:HasStream="true" sap:content-version="1">
<Key>
<PropertyRef Name="DocumentId"/>
</Key>
<Property Name="DocumentId" Type="Edm.String" Nullable="false" MaxLength="40" sap:unicode="false" sap:label="Doc. ID" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="OrderId" Type="Edm.String" Nullable="false" MaxLength="12" sap:unicode="false" sap:label="Order" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="DocumentType" Type="Edm.String" Nullable="false" MaxLength="10" sap:unicode="false" sap:label="Document type" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="FileName" Type="Edm.String" Nullable="false" MaxLength="255" sap:unicode="false" sap:label="Char255" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="FileContent" Type="Edm.Binary" Nullable="false" sap:unicode="false" sap:label="File Content" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
</EntityType>

Can someone explain how to load data into the attachment?

Thank you

Best Regards,

Nuno Oliveira

View Entire Topic
bill_froelich
Product and Topic Expert
Product and Topic Expert

The big things is that you need to save out the attachment to the device (like in the documents folder) so you can reference the path to the file when calling createAttachementEntry.

c_chowdary
Participant
0 Kudos

Hi bill.froelich , is it possible to achieve the same functionality in MDK Web as creatAttachmentEntry function is only for Android and IOS.

For example, I have image URL and want to populate the attachment control with the file from URL.