且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何分析SAP UI5应用的undefined is not a function错误

更新时间:2022-09-02 13:07:50

Recently I meet with an annoying Javascript error “undefined is not a function” during my Fiori development. After debugging the framework code for several hours

如何分析SAP UI5应用的undefined is not a function错误, I finally find a more efficient way to find the exact source code which causes the trouble. I would like to share this small tip with you and hope it could help.


Issue: When I am doing test on my application on a local tomcat, I could only see an empty screen.


For sure there must be some Javascript error occurred.

如何分析SAP UI5应用的undefined is not a function错误如何分析SAP UI5应用的undefined is not a function错误如何分析SAP UI5应用的undefined is not a function错误如何分析SAP UI5应用的undefined is not a function错误Conclusion

Although this error is raised in UI framework js file, it is however an absolute application issue: the url of OData is defined in Configuration.js file by application as metadata, and UI framework in the runtime will ask for it by calling some callback functions defined by application and then consume it. Framework will assume always a String for OData service url returned by application.

After the following fix is done on application, the issue is fixed.

如何分析SAP UI5应用的undefined is not a function错误Any other alternative solution?

Later on I find another approach to find the position ( line 154, column 36 ) even without debugging.


I test my app with Firefox. To my surprise, it could directly display more detail about this error compared with Chrome: “j.serviceUrl.indexOf is not a function”.

如何分析SAP UI5应用的undefined is not a function错误如何分析SAP UI5应用的undefined is not a function错误