cancel
Showing results for 
Search instead for 
Did you mean: 

Master Detail App Cannot read property 'getValue' of undefined in Controller

former_member435556
Participant
0 Kudos

Hi Experts,

I am using a template of Master Detail Application for one my application, I want to update table by using Approve Semantic button for this i am using Update.Model function but when i get value for this i got error Can't read Property 'GetValue' of undefined. I know i am making very Basic Mistake here but i already Browsed so much but couldn't find any clue to solve this issue . Thanks in Advance.

sap.ui.define([
"zbps/controller/BaseController",
"sap/ui/model/json/JSONModel",
"zbps/model/formatter"
], function (BaseController, JSONModel, formatter) {
"use strict";
return BaseController.extend("zbps.controller.Detail", {
formatter: formatter,
/* =========================================================== */
/* lifecycle methods                                           */
/* =========================================================== */
onInit : function () {
// Model used to manipulate control states. The chosen values make sure,
// detail page is busy indication immediately so there is no break in
// between the busy indication for loading the view's meta data
var oViewModel = new JSONModel({
busy : false,
delay : 0,
lineItemListTitle : this.getResourceBundle().getText("detailLineItemTableHeading")
});
this.getRouter().getRoute("object").attachPatternMatched(this._onObjectMatched, this);
this.setModel(oViewModel, "detailView");
this.getOwnerComponent().getModel().metadataLoaded().then(this._onMetadataLoaded.bind(this));
},
onSemanticButtonPress: function (oEvent) {
//var oViewModel = sap.ui.getCore().getModel("oViewModel"); 
var oViewModel = this.getModel("detailView"); 

var that = this;
// CREATE******************
if ("Approve" == oEvent.oSource.mProperties.text) {
var obj = {};

"ERROR"  Cannot read property 'getValue' of undefined in Controller"
obj.Belnr = that.getView().byId("Belnr").getValue(); " Error Point  <<<<<<<-----
obj.Gjahr = that.getView().byId("Gjahr").getValue(); 
//obj.Gjahr = "2018";
var updateurl = "/MasterBPSSet(Belnr='"
+ that.getView().byId("Belnr").getValue() + "')";

oViewModel.update(updateurl, obj , null);

}
var sAction = oEvent.getSource().getMetadata().getName();
sAction = sAction.replace(oEvent.getSource().getMetadata().getLibraryName() + ".", "");
sap.m.MessageToast.show("Pressed: " + sAction);
},
smarchesini
Active Contributor
0 Kudos

Hi Amir,


Belnr and Gjahr element are binding by some model ?

Accepted Solutions (0)

Answers (0)