cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Smart Link in Fiori Elements

TahirLeonenko
Explorer
297

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

ok in that case( add the smartLink to all elements in the column "Sales Document" of  table), the association Consumption.semanticObject comes to the rescue. link

In your CDS view for table, enhance it with the @Consumption.semanticObject annotation.

for example:-

@AbapCatalog.sqlViewName: 'ZSALES_DOC'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Sales Document List'
define view entity ZC_SalesDocument as select from ZI_SalesDocument {  

  @ui.lineItem: [{ position: 10, type: #STANDARD }]  
  @ui.identification: [{ position: 10 }]  
  @Consumption.semanticObject: 'SalesDocument'  // Enables SmartLink  
  key SalesDocument as SalesDocument,  

  @ui.lineItem: [{ position: 20 }]  
  Customer,  

  @ui.lineItem: [{ position: 30 }]  
  NetAmount  

}

Thanks,

Arun

 

 

TahirLeonenko
Explorer
0 Kudos
Hi Arun, thank you for your help and time! I tried doing what you instructed me to do, but it is not working. For some reason commenting does not allow my to format any code or etc., so I've posted an "answer" on this post with the relevant code that I've created so I can achieve the desired affect of having two semantic objects annotating my Sales Document field. Could you please take a look at it and advise on what needs to be changed? Thank you for your time and knowledge!