cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a field mandatory in Fiori App?

Vivek_Hegde
Active Contributor
0 Kudos

We have a simple fiori app in solman knows as Create Incident, which basically allows end user to report CRM incident. My question is how to make some input fields as mandatory in the Create Incident app ?

In the app, one of the fields (Title) is a mandatory field by default. I would like to make Configuration Item also as mandatory field. Could you throw some lights here on how to do. Please consider, I am a novice when it comes to Fior/UI5 development, so if you could explain me or give me some hints then I would read and figure out 🙂

Thanks,

Vivek

Andres_Vargas
Participant
0 Kudos

Hi Vivek,

Do you find a good step by step guide to do this?

View Entire Topic
leonikussmaul
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Vivek,

This should be quite simple to achieve.

In your view, you can locate the property that you'd like to validate as mandatory and set the property required to true. You can then use the change/liveChange event handler of the Input field to set the ValueState to Error if the value is empty.

<Label text="ConfigurationItem" required="true"/> <Input liveChange="onValidate"/>
onValidate: function(oEvent){
var oInput = oEvent.getSource();
if(!oInput.getValue()){
oInput.setValueState("Error");
//optional value state text 
oInput.setValueStateText("This field is required");
}

Please note that you will also need to "reset" the Value State, for this you can define a ternary operator to set it either to Error or to None.

oInput.setValueState(oInput.getValue === "" ? "Error" : "None");
Andres_Vargas
Participant
0 Kudos

Hi Leoni,

Could you please explain with more details that change?


I'm new in UI5 development and, as I know, today I'm not able to use the WEB IDE to make the correction.