cancel
Showing results for 
Search instead for 
Did you mean: 

Fiori Elements Object Page edit mode, form validation and events

former_member321811
Participant
0 Kudos

Hi,

I'm using the List Report template to display some objects stored in a Z table in my backend. Users should be able to edit these objects and some fields are mandatory so I'm using the field-control annotation to indicate which fields are required.

However when the Save button is pressed, the request is sent to the backend even if the required fields are empty. I'd like the app to validate the form first and then send the request only if the data is valid (i.e required fields are not empty).

Is there a way to attach an event handler to catch the Save event? I know there is an afterSave event but it seems like I need a beforeSave event.

Cheers,

Pierre

maheshpalavalli
Active Contributor
0 Kudos

Hi Pierre Dominique

are you using the draft enabled application or the normal fiori list report template?

BR, Mahesh

Accepted Solutions (0)

Answers (4)

Answers (4)

ChrisL
Advisor
Advisor
0 Kudos

Hi,

I faced exactly the same problem.

After searching through different blogs and documentations, I finally found the following solution, which worked for me using BOPF and Fiori Elements:

1. Ensure that your annotation
@ObjectModel.mandatory: true
is used on the transactional CDS layer, i.e. the CDS that creates the BOPF object.

2. In the BOPF you have to add a validation, lets call it Mandatory_Check and put in the class /BOBF/CL_LIB_V_MANDATORY_ATTR and activate. You do not need to implement anything, the library takes care automatically.

As a result you will be notified in your Fiori app, when you try to save the entity without setting a values for the field you annotated.

Hope, this helps.

Best

Christian

0 Kudos

Hi Pierre,

Were you able to able to validate mandatory fields from UI5 in ObjectPage of fiori elements?

I am also facing the same issue. Please help.

Regards,

Rahul Kumar Jain

maheshpalavalli
Active Contributor
0 Kudos

Hi Pierre Dominique

I checkd for this functionality for some time, I couldn't find any event called from the standard code 😞 .. only saw that aftersave is called.

Is there any issue with validating in the BOPF?

BR,
Mahesh

former_member321811
Participant
0 Kudos

Well it would be a lot nicer to validate on the client, show the required fields and not send the request if required values are missing. I'd like to have the same kind of behaviour we have when using the nullable property set to false and UI5 >1.60. The validation is done on the client and required fields are highlighted (ValueState is set to Error). It is a much better UX for the user.

Pierre

maheshpalavalli
Active Contributor
0 Kudos

It could be a lot better, maybe they don't want to repeat the checks. If are putting a check in the UI then it has to be available in the backend as well because if we access the odata directly, it will not have UI checks. That may be the reason why they are restricting some functionality in the UI.

former_member321811
Participant
0 Kudos

I'm using the standard list report template without the draft feature.

Pierre