Skip to Content

Note : This issue was specific to the chrome version 34 which has been fixed in the later versions & this workaround is no more needed.

Hey All,

If you get an error as below when you do oData Create,

oData.JPG

Open your console and execute the below code & check if your app works (don’t refresh after executing this code in console) https://gist.github.com/arv/9529994


if (!Document.prototype.createAttributeNS) {
  Document.prototype.createAttributeNS = function(namespaceURI, qualifiedName) {
   var dummy = this.createElement('dummy');
   dummy.setAttributeNS(namespaceURI, qualifiedName, '');
   var attr = dummy.attributes[0];
   dummy.removeAttributeNode(attr);
   return attr;
  };
}
if (!Element.prototype.setAttributeNodeNS) {
  Element.prototype.setAttributeNodeNS = Element.prototype.setAttributeNode;
}














If your app works like a charm 🙂 , then the reason for the above error is just because Chrome has removed some DOM Level 2 API’s. Internally data.js in UI5 uses two functions

          document.createAttributeNS() ,  document.setAttributeNodeNS()

which have been removed from chrome’s API. The workaround code would manually add those functions to the DOM’s document Object.

So, till this is fixed you can create a new js file say, workaround.js and copy the code posted above and import it to your ui5 app index.html as

<script src=”workaround.js”></script>

Once this issue is resolved, you can remove the workaround script 🙂 This is one of the workaround available.

For FIORI Apps that are loaded through component rather than index.html , you can do either of below steps.

  • You can do jQuery.sap.require(“folderLocation.workaround”); in your app.js or component.js . But make sure you register the folderLocation using jQuery.sap.registerModulePath() or sap.ui.localResources()

                                                       (OR)

         

  • Alternative for above one & much simpler approach, copy the code of workaround and paste it anywhere before you do the first oData crud operation.

Note : I’d suggest you can go for 1st approach only if you know how to import javascript using jQuery.sap.require else go for the second one.


Regards

Sakthivel

To report this post you need to login first.

30 Comments

You must be Logged on to comment or reply to a post.

    1. Sakthivel Elango Post author

      Got it!

      1) You can do jQuery.sap.require(“folderLocation.workaround”); in your app.js or component.js . But make sure you register the folderLocation using jQuery.sap.registerModulePath() or sap.ui.localResources()

                    

      2) Alternative for above one, copy the code of workaround and paste it anywhere before you do the oData crud operations.

      (0) 
  1. Jens Niemeyer

    Hi,

    this bug causes a long night yesterday 😡

    Finally this morning I found this blog.

    Thanks a lot!!!

    My question is: Is there are fiix for SAPUI5 Odata lib or do I have to apply the code above in my program before each OData.create call?

    Chers

    Jens

    (0) 
    1. Aksel Wienke

      I just applied the above workaround – works fine!

      So simply put the above code in a file and include it in your index.html like Sakthivel said:

      “So, till this is fixed you can create a new js file say, workaround.js and copy the code posted above and import it to your ui5 app index.html as

      <script src=”workaround.js”></script>”

      (0) 
    2. Chandrashekhar Mahajan

      This issue is occurring in latest chrome version 34. see Issue 347506 –  chromium –  DOM Level 2 API not available anymore (createAttributeNS, setAttributeNodeNS, …) –  An ope…

      We need to watch this thread for further updates. also see this tweet on OpenUI5 account.

      (0) 
  2. Tamas Szirtes

    Hi Sakthivel,

    I was almost loosing hair on this 😉 Thanks a lot for your post!!!!

    Regards,

    Tamas

    (0) 
  3. Felipe Picada

    Another 3hrs saved here… There is no SAP Note about it yet!!!!

    All you receive is the message: “undefined is not a function”!

    var attribute =

                dom.createAttributeNS…. tell me about it.

    That’s the good thing about this open stuff, they can remove things when they want. No.

    Thanks for posting it.

    (0) 
  4. Sumit Sharma

    Dear Sakthivel,

    Thanks for your helpful post. I invested lot of time to get the Create working, should have searched for this error in SCN earlier.. 😛

    Cheers,

    Sumit

    (0) 
  5. Aksel Wienke

    Official solution propose by SAP:

    “Dear customer,

    there are two ways to solve the  issue with Chrome 34 and Fiori Apps:

    – either you use Chrome 35 (that was recently released)

    – or you use the  UI5 version 1.20.6 or higher.”

    (0) 
  6. Timothy Muchena

    Hi

    Thank you for the post.

    I am still getting this error even after implementing the solution. I am able to display the master page. The error appears when I click an item on the master page to view the detail page for the selected item

    Undefine error.PNG

    Regards

    (0) 
    1. Sakthivel Elango Post author

      It seems the issue you face is not related to the one explained in the blog. I would suggest to open up question in the UI5 community on the same.

      (0) 

Leave a Reply