on 01-15-2019 9:27 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
I'm using the standard list report template without the draft feature.
Pierre
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.