Skip to Content
0
Aug 11, 2022 at 09:12 AM

SAP MDK - Creating an attachment entry using createAttachmentEntry function.

517 Views

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