Skip to Content

Fiori Extension: Possible to override a utility/helper file?

Hello everyone,

I extending a Fiori Standard application. So far I successfully extended the app table with additional columns, changed the service, added local UI model to the application and added additional custom actions (Buttons etc.).

Issue:

However, in addition I would like to modify a function which held in an helper file/utility (lets call in utility.js). Basically the function is handling some default values shown on startup. The tricky thing is that the utility.js and its function is called on application startup. Furthermore, the utility is not part of the "official" extension concept and not listed as view or controller when the Extension Wizard is being started.

Approaches applied so far:

Trying to tackle the issue I added the utility file I want to replace manually in the manifest properties. I also copied the original utility.js file and modified the function. No luck.

I also tried to call the utility file directly when the component.js file is being loaded hoping to override the original file. Nope!

Last but not least I tried to use controller hook (onDataReceived) to call the modified function (in a modified utility.js) hoping to change the standard behavior after all the business data being loaded. Similar how it works when overriding formatters at the source code ( https://blogs.sap.com/2015/07/27/overriding-source-files-in-the-util-folder-when-extendingcustomising-fiori-apps/ ). No success!

Question:

So far no one of the approaches worked out. Now I`m wondering if it is possible to override a function in an utility which is being loaded on application startup?

Any hints are welcome. Thanks!

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Posted on Oct 03, 2018 at 02:38 PM

    I also tried to call the utility file directly when the component.js 
    file is being loaded hoping to override the original file. Nope!

    how you call ? how you override?

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      the original utility was not overwritten. That's the issue. I did check the network tab on app start and could see that both files being loaded. So basically the original file ("sap_utility.js" and the modified file "utility.js" were loaded).

      I added following statement to the component.js:

      jQuery.sap.require("namespace.util.utility");

      The issue is that the function I would like to modify is being called as part of an UI Element which is being constructed in the original utility. So sap_utility.js starts basically with:

      sap.ui.core.Element.extend()

      There it contains methods, events, properties but also the function which being called and I like to modify.As far as I can see the utility is constructed in the Configuration.js file of the application using:

      new namespace.util.sap_utility(); 

      So at the current point its unclear to me how (and if) I can call the utility.js instead of the sap_utility.js on application start. The Configuration.js file is not available in the extension project.

  • Posted on Oct 04, 2018 at 01:37 PM
    jQuery.sap.require("namespace.util.utility"); you should load sap's utility, not yours, then start your manipulation.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 05, 2018 at 01:41 PM

    if it is object, utility.****= the thing you want

    if it is class(function), utility.prototype.*****=the thing you want

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 10, 2018 at 08:34 AM

    Hey Jun,

    I tried to load the sap_utility on application start adding the statement below to the component.js

    jQuery.sap.require("namespace.util.sap_utility");

    But the app is breaking already showing something:

    failed to load 'part1/part2/part3/util/sap_utility.js' from /sap/bc/ui5_ui5/ui2/ushell/resources/~20171109155700~/part1/part2/part3/util/sap_utility.js: 404 - NOT FOUND sap.ushell.renderers.fiori2.Shell.controller

    No chance to reach the point where I can modify the utility. However, for other features it is working fine (e.g. overwritting a function from a formatter).

    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.