cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Smart Link in Fiori Elements

TahirLeonenko
Explorer
300

Main goal: Annotate an EntityType's property with multiple semantic objects.

On the website: Demo Kit - SAPUI5 SDK, in API reference, there is something called Smart Links which allow you to annotate a single property with multiple semantic objects. If you go to Samples and search for it, you can find an example for "Smart Link with field annotated to multiple SemanticObjects", and by clicking on the "Show Source Code" button, it seems like the view.xml file is implemented as:

<SmartLink text="{Name}" semanticObject="dummy" additionalSemanticObjects="demokit_smartlink_example_09_SemanticObjectNameAdditional,demokit_smartlink_example_09_SemanticObjectNameAdditional2" enableAvailableActionsPersonalization="false"/>

and there is a controller.js:

sap.ui.define([ 'sap/ui/core/mvc/Controller', 'sap/ui/comp/navpopover/SemanticObjectController' ], 
function(Controller, SemanticObjectController) { 
"use strict"; 
return Controller.extend("sap.ui.comp.sample.smartlink.example_09.Example", { onInit: function() {
SemanticObjectController.destroyDistinctSemanticObjects(); 
this.getView().bindElement("/ProductCollection('1239102')"); 
} 
}); 
}); 

However in my own Fiori project which I've created from "SAP Fiori Generator" in SAP Business Application Studio, I do not have such a views.xml file, nor anything that resembles it. I am mainly using an annotations.xml file, which implements a table using:

<Annotations xmlns="http://docs.oasis-open.org/odata/ns/edm" Target="SAP.ZZ1_C_SLCNTRINFOQRYType/SalesDocument"> 
  <Annotation Term="com.sap.vocabularies.Common.v1.SemanticObject" String="SalesContract"/> 
</Annotations> 
<Annotations Target="SAP.ZZ1_C_SLCNTRINFOQRYType"> 
  <Annotation Term="UI.LineItem" Qualifier="tab0"> 
    <Collection> 
      <Record Type="UI.DataField"> 
        <PropertyValue Property="Label" String="Sales Document"/> 
        <PropertyValue Property="Value" Path="SalesDocument"/> 
      </Record> 
      ... 
    </Collection> 
  </Annotation> 
  ... 
</Annotations>

In this case, the first Annotations element populates all references to the SalesDocument property with navigation to the apps that have the semantic object SalesContract. However I want to add a second semantic object for app navigation, "AccountingDocument", which I do not believe is possible with this annotation. Could someone please explain how I could adapt the sample Smart Link example to my case, or suggest an alternative?

Thank you for the help!

 

 

 

 

View Entire Topic
ArunJacob
Participant

Hi,

When using Fiori Elements, the app is primarily metadata-driven, which explains why you don't see a views.xml file. Instead, you're working with an annotations.xml file.

To add a second semantic object for app navigation, "AccountingDocument", please try the below:-

1) Create a view.xml and corresponding controller holding the 

<SmartLink text="{Name}" semanticObject="dummy" additionalSemanticObjects="demokit_smartlink_example_09_SemanticObjectNameAdditional,demokit_smartlink_example_09_SemanticObjectNameAdditional2" enableAvailableActionsPersonalization="false"/>

2) Update the manifest.json

"routes": [
    {
        "pattern": "account",
        "name": "AccountView",
        "target": "AccountView"
    }
],
"targets": {
    "AccountView": {
        "viewType": "XML",
        "viewName": "<namespace>.view.AccountDocument"
    }
}

This way we can add custom UI elements (like smartLink) beyond what annotations provide.

 

TahirLeonenko
Explorer
I probably wasn't clear enough, but I want to add the smartLink to all elements in the column "Sales Document" of my table. How would I adapt the <SmartLink> element or controller to do so?