cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 Accessing JS files in other apps

antonette_oberholster
Active Contributor
0 Kudos

Hello Guys

Something tell's me this is an easy one but somehow I just can't get it working.

So I have a JS file in app 1 and would like to call is using app 2.

sap.ui.define([
	"sap/ui/base/Object"
], function (Object) {
	"use strict";    
   	return Object.extend("ehsLibraryAppId.utilities.LoggedOnUser", {	   
   		getLoggedOnUser : function (oEvent) {
   			
   			return("It works");
   			 		  	      	
   		}
   	});   	
});

I've tried calling it in the Component of app2 like this:

// register EHSLibrary
			jQuery.sap.registerModulePath("ehslibrary.utilities", "../zehslibrary/utilities");						
			jQuery.sap.require("ehslibrary.utilities.LoggedOnUser");

var getUser = new ehslibrary.utilities.LoggedOnUser();
var myuser = getUser.getLoggedOnUser(oEvent);
console.log("myuser");
console.log(myuser);

I'm expecting console to write "It works" . . . . It doesn't work . . . .

Any ideas please?

Thanks

Antonette

Accepted Solutions (0)

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

first check the network tab to see if it tries to load the requested js.

antonette_oberholster
Active Contributor
0 Kudos

Hi Jun

Thanks I checked and it is loading the file correctly.

The error I'm getting is:

"UIComponent.js:6 Uncaught ReferenceError: ehslibrary is not defined"

Thanks

Antonette