Skip to Content
0

SAPUI5 - this.getView() is not a function

May 03, 2017 at 02:48 PM

349

avatar image

I am trying to get the input value, but when I call the function I get the error this.getView() is not a function

Below is the function in controller

 handleConfirmationMessageBoxPress: function(oEvent) {
        var bCompact = !!this.getView().$().closest(".sapUiSizeCompact").length;
        MessageBox.confirm(
            "Deseja confirmar a transferência?", {
                   icon: sap.m.MessageBox.Icon.SUCCESS,
                   title: "Confirmar",
                    actions: [sap.m.MessageBox.Action.OK, sap.m.MessageBox.Action.CANCEL],
                    onClose: function(oAction) {
                      if (oAction == "OK"){
                          var loginA = this.getView().byId("multiInput").getValue();
                          alert(loginA)
                          MessageToast.show("Transferência efetuada");

                      }else{
                         // MessageToast.show("Transferência não cancelada");
                           }

                        },
                        styleClass: bCompact? "sapUiSizeCompact" : ""
            }
        );
    }

And here is the input in the view

 <m:Input id="multiInput" value="teste" placeholder="Clique no botão ao lado para buscar o usuário" showValueHelp="true" valueHelpRequest="valueHelpRequest" width="auto"/>
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Jun Wu May 04, 2017 at 05:15 AM
0
handleConfirmationMessageBoxPress:function(oEvent){
        var bCompact =!!this.getView().$().closest(".sapUiSizeCompact").length;

var that=this;
        MessageBox.confirm("Deseja confirmar a transferência?", {icon:sap.m.MessageBox.Icon.SUCCESS,title:"Confirmar",
                    actions:[sap.m.MessageBox.Action.OK,sap.m.MessageBox.Action.CANCEL],
                    onClose:function(oAction){if(oAction =="OK"){
                          var loginA = that.getView().byId("multiInput").getValue();
                          alert(loginA)
                          MessageToast.show("Transferência efetuada");}else{// MessageToast.show("Transferência não cancelada");}},
                        styleClass: bCompact?"sapUiSizeCompact" : ""});}
Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thank's for answer Jun Wu

0

The reason for this variable not available, was because you accessed it inside the Message internal functional call.

Jun stored this variable in that and accessed it using that.

Regards,

Sharath

0