This section provides sample code and explanations that help you to directly integrate the Share Dialog component into your custom SAP Fiori app.
The Share Dialog component is a dialog that contains the following, as shown in the figure below:
The sample code below demonstrates how you can integrate the following for the Share Dialog component:
The integration is done using the sap.ui.getCore().createComponent() function, which is available in the SAPUI5 library.
Var oShareDialog = sap.ui.getCore().createComponent({ name: "sap.collaboration.components.fiori.sharing.dialog", id: "shareDialog", settings: { object: oDisplayObject, externalObject: oExternalObject, attachments: oAttachments } });
The function sap.ui.getCore().createComponent() enables you to create a UI component. You use this function to create the Share Dialog component, which expects a JSON object that has the following properties:
Property | Description |
---|---|
name | Namespace for the Share Dialog component (sap.collaboration.components.fiori.sharing.dialog ) |
id (optional) | Unique ID that you give to the Share Dialog component. If not provided, the framework creates an ID. |
settings (optional) | JSON object that contains the following properties:
|
The sample code below shows the object (oDisplayObject in the sample above) and contains information needed for rendering the Share dialog and for sharing to SAP Jam:
var oDisplayObject = { id: window.location.href, display: new sap.m.ObjectListItem("object_item",{ title : "SO 3212", number : "1K", numberUnit : "USD", firstStatus: new sap.m.ObjectStatus({text : "Open", state:"Warning"}) }), share: "Please take a look at this Sales Order." };
The oDisplayObject is a JSON Object that can have the following properties:
Property | Type | Description |
---|---|---|
id (optional) | sap.ui.core.URI | URL to navigate back to the same business object in your SAP Fiori application This is used to navigate back to the application from the feed entry created in SAP Jam for the business object. |
display (optional) | SAPUI5 Control | SAPUI5 control to be displayed as a header in the Share dialog Recommendation Use an
ObjectListItem
(sap.m.ObjectListItem),
as there is limited space available for the
header.
|
share (optional) | String | Note that appears as a default value for the Comments section
in the Share dialog This note is used as the body of the feed entry that is created in SAP Jam. |
var aFiles = []; aFiles.push( new sap.collaboration.components.fiori.sharing.attachment.Attachment( "c&h-snowy.gif", "image/gif", "http://localhost:8080/uploads/c&h-snowy.gif")); aFiles.push( new sap.collaboration.components.fiori.sharing.attachment.Attachment( "marvel.jpg", "image/jpg", "http://uspalw183.dhcp.pal.sap.corp:8080/uploads/marvel.jpg")); var oAttachments = { attachmentsArray: aFiles };
Attachments Properties
The oAttachments object is a JSON object that can have only one property:
Attribute | Type | Description |
---|---|---|
attachmentsArray (optional) | Array | Array of attachments that will be uploaded to SAP Jam. Each
attachment is an object
(sap.collaboration.components.fiori.sharing.attachment.Attachment)
where its constructor expects the following parameters:
|
var oExternalObject = { appContext: "UDBO", odataServicePath: "/sap/opu/odata/sap/ZMCN_TEST_SERVICE_1_SRV/", collection: "TestCollection", key: "'myExtObj'", name: "User Defined BO myExtObj", summary: "not being used" };
Business Object Properties
The oExternalObject object is a JSON object that must have the following properties:
Attribute | Type | Description |
---|---|---|
appContext | String | Application context Example CRM, SD, and so on
|
odataServicePath | String | Relative path to the OData Service
Example /sap/opu/odata/sap/ODATA_SRV
|
collection | String | Name of the OData Collection
Example Account,
Opportunity,
and so on
|
key | String | Identifier for a particular instance of the business object. It can be a simple ID or
a compound key.
Example 123,
ObjectID='123',
ObjectID='123',ObjectType='BUS000123',
and so on
|
name | String | Short name of the business object Example Sales Order
123,
Opportunity
123, Account
123, and so
on
|
var aFiles = []; var fileHostUrl = 'http://localhost:8080'; aFiles.push(new sap.collaboration.components.fiori.sharing.attachment.Attachment( "c&h-snowy.gif", "image/gif", fileHostUrl + "/uploads/c&h-snowy.gif")); var attachments = { attachmentsArray: aFiles }; var object = { id: window.location.href, display: new sap.m.ObjectListItem("object_item2",{ title : "SO 3213", number : "10K", numberUnit : "USD", firstStatus: new sap.m.ObjectStatus({text : "New"}) }), share: "This is a new Sales Order" }; var externalObject = { appContext: "UDBO", odataServicePath: "/sap/opu/odata/sap/ZMCN_TEST_SERVICE_1_SRV/", collection: "TestCollection", key: "'myExtObj2'", name: "User Defined BO myExtObj2", summary: "not being used" }; this.oShareDialog.setSettings({ object: object, externalObject: externalObject, attachments: attachments });