Skip to Content
Author's profile photo Former Member

Quick workaround to solve issue regarding oData Create in Latest Chrome! (version 34)

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

Assigned tags

      30 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Andrew Konovalov
      Andrew Konovalov

      Hello, Elango.

      Big thanks to you for really helpful post.

      Author's profile photo Aksel Wienke
      Aksel Wienke

      Best!

      ...maybe you have also a good SAPnote to implement for FIORI-Apps?

      Author's profile photo Aksel Wienke
      Aksel Wienke

      No, the current FIORI-Apps face also the problem regarding CRUD and latest Chrome...and there you can't change the index.hml

      Author's profile photo Former Member
      Former Member
      Blog 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.

      Author's profile photo Joao Sousa
      Joao Sousa

      This is one serious bug... Are they using private/deprecated apis?

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      The api isn't deprecated, but it's removed !

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Aksel Wienke
      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>"

      Author's profile photo Chandrashekhar Mahajan
      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.

      Author's profile photo Former Member
      Former Member

      thanks for the workaround! Helped a lot!

      Author's profile photo Former Member
      Former Member

      Thanks for that! We are on a project, this hint saved a lot of time and trouble.

      Author's profile photo Tamas Szirtes
      Tamas Szirtes

      Hi Sakthivel,

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

      Regards,

      Tamas

      Author's profile photo Rauf Shaikh
      Rauf Shaikh

      Thank you sharing this with such great details. 🙂

      Regards,

      Rauf

      Author's profile photo Former Member
      Former Member

      Perfect! (Y)

      Author's profile photo Krishna Kumar S
      Krishna Kumar S

      Hi Shaktivel,

      thanks for the great blog... really helpful....

      Author's profile photo Ruediger Mueller
      Ruediger Mueller

      This was starting to drive me crazy. But with this great blog I am able to spend some more time outside in the sun 🙂

      Author's profile photo Former Member
      Former Member

      thank u so much for sharing 🙂

      Author's profile photo Christian Schmitz
      Christian Schmitz

      Thanks a lot!!!!!!!!!!!!!!!!!!!!!

      Author's profile photo Former Member
      Former Member

      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.

      Author's profile photo Former Member
      Former Member

      Trick on github link?

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Krishna Kishor Kammaje
      Krishna Kishor Kammaje

      Sakthivel,

      I am seeing this error in Firefox now. The above work around does not work. Any clue?

      regards

      Krishna

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      which version of firefox ?

      Author's profile photo Krishna Kishor Kammaje
      Krishna Kishor Kammaje

      I have Firefox 29.0.1

      Author's profile photo Krishna Kishor Kammaje
      Krishna Kishor Kammaje

      Please ignore. It seems to be a different issue, but very much browser dependent. I will update once I find it.

      Author's profile photo Former Member
      Former Member

      Are you sure it's the same issue, looking on bugzilla it looks like removing was discussed, but decided against??

      https://bugzilla.mozilla.org/show_bug.cgi?id=977960

      Regards,

      Jason

      Author's profile photo Aksel Wienke
      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."

      Author's profile photo Timothy Muchena
      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

      Author's profile photo Former Member
      Former Member
      Blog 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.