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,

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 :smile: , 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 :smile: 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