Introduction
The oData annotations that tell which of the OData properties contain e.g. a phone number, a part of a name or address, or something related to a calendar event or an analytic query. This is important for apps running on mobile devices that want to seamlessly integrate into contacts, calendar, and telephony.
In the last blog, I wrote how to create annotations and consume it in a Fiori application.
When we made our application, it created a local reference for our annotations and the next time when we run our application, the local copy of annotations is called and the view is rendered per it.
This is how our application structure looks like:
Here we can see the local service with the metadata.xml which holds the annotation properties.
Well how the local metadata is accessed. Let’s have a look at the maniest.json
Here in the above picture, we can see the uri of odata service , and then in settings we can see the uri of local service that is referring to the metadata.xml
But we can see two things.
The metadata is dependent on the service it is bound to.
If there is change in odata , the local metadata is still the same and thus won’t reflect any change in UI.
In a case where there is change in service pack and we need to change our annotations or the odata , shall we go back to the application and regenerate the metadata , or what if we have the ability to get our annotations from another server and then render it with odata coming from some other server .
In this blog, will make our application independent. No need to depend on local service to get annotations.
Steps :
Go to manifest.josn, Add the following setting to it and you will be good to go with annotations coming separately from OData service or from a different service url.
"dataSources": {
"mainService": {
// service uri
"uri": "/sap/opu/odata/sap/ZANNOTATIONS_BLOG_SRV/",
"type": "OData",
"settings": {
// telling that we are getting annotations from "from Server"
"annotations" : ["fromServer"]
}
},
//specifying the annoations settings
"fromServer" :{
// annoations uri , we can see its coming from different project
"uri" : "/sap/opu/odata/SAP/ZANNOTATIONS_SRV_04/$metadata",
// telling that it is a odata annotaiton
"type": "ODataAnnotation"
}
},
and we are done.