Skip to Content

[SAPUI5] Extending an Fiori Elements Object Page with extensionAPI

Hi UI5-Developers,

I created a List Report Application with Fiori Elements and then made a few changes with the annotation modeller.
Now I am trying to implement an header extension for the Object Page which looks like this:

The view shall implement the URLHelper library and bind the actual data of the odata model used by the application. (https://ui5.sap.com/#/api/sap.m.URLHelper). The screenshot displays the example from the API with a draft JSONModel.

My intention is to bind the view to the context of the Object Page so that I can bind the mail address of that object and using the list as a way of hyperlinking the mail address.
Now I am basically wondering how I use my odata model in the extension controller.

To do that I thought of using the extensionAPI like this post states https://answers.sap.com/questions/12690603/how-can-i-get-the-model-data-of-the-object-page-in.html. However, right at the start, I am getting following error code when trying to use the extensionAPI object:

The Reference does not seem to be wrong, since I am reaching the functions defined by the API under sources in my dev tools.

Controller Code:

sap.ui.define([
	"sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel", "sap/suite/ui/generic/template/ObjectPage/extensionAPI/ExtensionAPI"
], function (Controller, JSONModel, extensionAPI) {
	"use strict";

	return Controller.extend("namespace.ext.controller.CommunicationExtension", {
		onInit: function (evt) {
			var oModel = new JSONModel({
				"SupplierCollection": [{
					"Tel": "+49 6227 747474",
					"Sms": "+49 173 123456",
					"Email": "john.smith@sap.com"
				}]
			});
			this.getView().setModel(oModel);
		},
		onAfterRendering: function (evt) {
// raises type Error -> this.extensionAPI is undefined this.extensionAPI.getViewId(); }

Thank you very much for your help.

draft.png (8.2 kB)
cbmci.png (24.2 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jul 22, 2020 at 04:00 AM

    Hello Marcel,

    When you do a break out code there are multiple controllers which can come in to the context. For an example in case you have View extension, you could have a controller associated to this view extension. This is pure UI5 logic and Fiori elements doesn't play any role in this. You could also have an Extension controller to the standard view of LR/ALP/OP Component. The extensionAPI object is associated with the Standard components extension controller. From your controller extension code it looks to me is a View extension and that is why you don't have this reference.

    Regards,

    Vinod

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.