I have the following function where I call an OData service to validate input and want to clear the source component if the value is not valid.
After calling the service, it does not recognize the oEvent.getSource().setValue
in the success callback and I'm unable to clear the component.
validateEquipment: function (oEvent) {
var _this = this;
var circ7 = _this._oComponent.getModel("LoggedInUser").getData().circ7;
var equipmentNumber = oEvent.getSource().getValue();
var equipmentType = "1";
if (oEvent.getParameter("id").indexOf("containerID") > -1) {
equipmentType = "2";
}
var module = "";
if (circ7 && equipmentNumber.length === 10) {
_this._oComponent.getModel("serviceMetaData").read("Equipment_Look(EquipmentType='" + equipmentType + "',EquipmentNumber='" + equipmentNumber + "',Module='" + module + "',Circ7='" + circ7 + "')", {
success: function (data) {
if (data && data.ErrorMessage === "") {
// ...
} else if (data) {
oEvent.getSource().setValue('');
MessageBox.error(data.ErrorMessage);
}
},
// ...
})
} else {
oEvent.getSource().setValue("");
MessageBox.error("Equipment " + equipmentNumber + " is invalid.");
}
}