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

Leave a Comment.