Among the CDS annotations for declaring constraints when modelling, there are a handful that can be used to drive behaviour and restrictions in Fiori UIs, by causing the generation of appropriate annotations in the service's metadata.
One of these annotations is @mandatory, and this causes an OData annotation to be generated on the target that corresponds to the element annotated in CDS:
<Annotations Target="...">
<Annotation Term="..." EnumMember="..." />
</Annotations>The OData vocabulary Common contains the term FieldControl. In the <Annotation ... /> element that is generated, there's an attribute Term which points to this term, and a second attribute EnumMember which contains the fully qualified value for that term, a value which represents "mandatory".
What is that fully qualified value?
This is a question from the June Developer Challenge on CAP Knowledge. And don't forget: always submit your answer as a hash, on its own - read the Taking part section of the intro post for more info. At the end of today, this question will be updated with links to further reading on this topic.
Further info:
- The @mandatory subsection in the Input Validation section, and the @mandatory subsection of the Field Control section within the Declarative Constraints topic has details on this.
- The FieldControlType section of the "Common" vocabulary definition lists the possible members for the
FieldControlterm. - The tutorial Understand how vocabularies are used in OData metadata documents on the SAP Tutorial Navigator explains how metadata can be extended using content organized into vocabularies.
- The blog post OData Deep Dive rewrite in the open has more on the mission to which the referenced tutorial belongs.
- The blog post A deep dive into CDS and OData annotations has lots on this topic.