2
votes

I'm new to SAP, UI5 and CDS annotations. I've created a CDS view and created the application using Web IDE Template project, list report template. The application works fine, but I want to add following validations

In my CDS I’m having a quantity field. I want to have a greater than zero value when user saving records through the List report application. Can I do it using UI5 annotations?

And In the CDS I have defined 2 key fields. In the application when trying to create duplicate record application navigates to an error page indicating error occurred. How can I validate duplicate records based on the key fields and give warning or error to customer when creating a new record?

Thanks in advance

2

2 Answers

1
votes

The building blocks for doing this are in place, but I can't confirm how much of it will be handled properly by the framework yet:

Validation Vocabulary - see Terms: minimum, and ConstraintType: FailureMessage.

SAP Common Vocabulary: SideEffectsType - see EffectType: ValidationMessage.

The sap.ui.generic.app.ApplicationController has a method executeSideEffects.

With those building blocks, one should theoretically be able to achieve both of your requirements.

0
votes

To anyone who is trying to do validations using annotations, I did not find a way to do the validations using annotations, in a consumption view when writing data.

I the only way I found to validate the inputs is to write the validation logic in the BOPF object crated when activating the CDS. But that will be in ABAP code and you need the basic ABAP knowledge.