cancel
Showing results for 
Search instead for 
Did you mean: 

If some drop down are mandatory and left blank by user, error message should be shown (SAP MII)

prityshaw
Explorer
0 Kudos
434

Hello,

These are my dropdown fields

and I want If some dropdown are mandatory and left blank by user, error message should come.

so help me to write code in the controller to get the error message when this are not selected or empty

Accepted Solutions (1)

Accepted Solutions (1)

priteshpatel65
Active Participant
0 Kudos

Hi prityshaw

As per my understanding you need a validation for blank input.

find below code might be its a help and also you can use value state error for fields.

CB - Cobobbox id
DP- Datepicker id
IN - Input id

if (this.getView().byId("CB1").getSelectedItem() === null) {
                    sap.m.MessageToast.show("Enter Value");
                    return;
                }
                else if (this.getView().byId("CB2").getSelectedItem() === null) {
                    sap.m.MessageToast.show("Enter Value");
                    return;
                }
                else if (this.getView().byId("CB3").getSelectedItem() === null) {
                    sap.m.MessageToast.show("Enter Value");
                    return;
                }
                else if (this.getView().byId("DP1").getDateValue() === null) {
                    sap.m.MessageToast.show("Enter Value");
                    return;
                }
                else if (this.getView().byId("DP2").getDateValue() === null) {
                    sap.m.MessageToast.show("Enter Value");
                    return;
                }
                else if (this.getView().byId("IN1").getValue() === "") {
                    sap.m.MessageToast.show("Enter Value");
                    return;
                }
                else if (this.getView().byId("IN2").getValue() === "") {
                    sap.m.MessageToast.show("Enter Value");
                    return;
                }
                else if (this.getView().byId("IN3").getValue() === "") {
                    sap.m.MessageToast.show("Enter Value");
                    return;
                }


This code not allow to filter without entering all value.

Regards

Pritesh Patel

Answers (1)

Answers (1)

suresh7
Explorer

Hi Prity,

Thank you for posting the question. You can validate the user-provided inputs on the action button click event in the controller file and can give the message in the message box or message toast.

For some code samples, you can refer to the SAP UI5 documentation (e.g. https://sapui5.netweaver.ondemand.com/sdk/#/controls)

It looks like it is your first time posting a question here, in that case below guidelines might be helpful.

- Community members might not be able to help with direct code snippets for your specific needs

- Please try different options for troubleshooting and do the research before posting the question. And mention what you tried and where you have issues so that some members can help.

- Please try to put the specific questions with detailing versions you are using, the exact error/issue where help is needed, etc.

Thank you.