on 2024 Jun 29 2:46 PM
Hello everyone,
I'm using CAP Node.js(odata v4) and for frontend I have used a list report & object page template with fiori elements. The issue is that when i throw an error on invalid user input, the input field on the object page isn't being highlighted. It does throw the error successfully but for some reason doesn't highlight the target. I have used the following code in the before(Create) handler :
The reason why the text input field is not being highlighted might be due to how the error target path is specified. Here are a few points to consider:
Correct Target Path: When calling req.error(...), ensure the target path is correct. The target should be a relative resource path correlating the error message with the input field. In draft scenarios, by convention, the target usually has the prefix in. For example:
req.error({ message: 'Name cannot be empty', target: 'in/items(ID=6,IsActiveEntity=false)/name', status: 422 })
Or:
req.error({ message: 'Name cannot be empty', target: 'in/name', status: 422 })
If the target path—also commonly named in SAPUI5/Fiori Elements as the binding path—is not specified correctly, the error message might not be propagated to the Message Popover correctly, resulting in a poor user experience. Therefore, it is crucial to ensure that the target path aligns with the field's binding path in the front end.
Mandatory/Required Fields: You could consider annotating the text input field as required in the model, or you could try the @mandatory annotation in your CDS model to mark fields as mandatory. This can help with validation and ensure that the UI framework correctly understands which fields are required. CAP provides generic features for data validation. If you haven't already, you can explore CAP's generic data validation features to ensure you leverage all available capabilities.
Additional Information:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The in prefix in your example is related to the action metadata of the associated action, where the in parameters are defined in an EDMX (Entity Data Model XML) file. This is commonly used in OData services to define the path of the entity set on which an action operates.
https://cap.cloud.sap/docs/releases/archive/2023/jan23#cds
User | Count |
---|---|
70 | |
8 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.