Get all metadata fields for odata service

In order to get all the metadata fields for oData metadata using javascript use the getServiceMetadata()

var oModel = this.getView().getModel();
var metadata = oModel.getServiceMetadata();

//Get the fields
var entityRef = metadata.dataServices.schema[0].entityType[0];
var listOfProperties = entityRef.property;

for (var i = 0; i < listOfProperties.length; i++) {
	var a = listOfProperties[i].name;
	console.log(a); // a is the field name
}

entityType[0] => change 0 to the index of the service path that you want

Learn SAPUI5

End users prefer to have any data available at any time and at any place. As a result, there are requirements for a broad range of devices and technologies to be able to meet this demand.

To download SAPUI5 gor to http://sap.github.io/ and download openui5

 

http://openui5.blogspot.com/p/ide.html

Continue reading