on 2022 Feb 05 6:46 AM
Greetings.
The title of my post pretty much describes my problem.
I am developing some prototype applications based on SAP Fiori Element (along with SAP CAP and SAP HANA DB).
I'm testing (and learning how to use various annotations). At the moment, all the annotations that I am using are at the level of the definition of the domain model (database) and the definition of the service. That is, at the level of CDS files.
I want to know:
What is the @Communication.IsPhoneNumber (SAP Vocabulary) annotation for?
And mainly, how is that annotation used? (some examples would be useful)
I have already tried, understood, and seen the effects of other annotations like @Communication.IsEmailAddress. This allows me, for example, to validate that the user's input is an email address (as I show in the first screenshot attached).
However, unlike what I expected, the @Communication.IsPhoneNumber annotation doesn't work the same or doesn't seem to work (I don't know if I'm not using it correctly). For example, I can enter any text string into a field annotated with @Communication.IsPhoneNumber (as shown in the second screenshot attached).
To further clarify the way I'm using the annotation (because maybe the problem is that I'm not using it properly), I'm sharing two code snippets below that show it.
1. I have a file (sme_common.cds) with common definitions for the entire project. In a part of that file is the following fragment:
type LongName : localized String(111);
type ShortDescription : localized String(111) @Core.Description;
type LongDescription : localized String(1111) @Core.LongDescription;
type EmailAddress : String(320) @Communication.IsEmailAddress;
type PhoneNumber : String(15) @Communication.IsPhoneNumber; // <---------------
type ComputingPath : String(4096);
type URL : String(2048) @Core.IsURL;
//----- Common number types<
type Percentaje : Decimal(2,2) @assert.range:[0,100] @Measures.Unit : '%';
2. In the domain model definition (Data), I have the following:
using { Country as SAP_Country } from '@sap/cds/common';
using { sme.common as SME } from '../common/sme_common';
entity Companies: SME.BaseMaster {
country : SAP_Country not null;
shortDescr : SME.ShortDescription;
longDescr : SME.LongDescription;
email : SME.EmailAddress @title: 'EMAIL';
phone : SME.PhoneNumber @title: 'PHONE'; // <---------------
myUrl : SME.URL @title: 'URL';
}
How can I validate that a data field accepts only strings that are valid phone numbers (such as +58 424-4164922 or 0412 422-8342) using SAP Fiori Elements annotations?
it's possible?
Thanks in advance for any help and/or suggestion.
Request clarification before answering.
Hi Isaac,
you can found more information about this feature/annotation in out documentation here.
You can also see an example in our show-case application
There is no UI validation possibility for phone numbers. The validation must be done in the background.
Best regards,
Thorsten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You've shared link to internal github repository, where we don't have an access 🙂 Is that same as this one https://github.com/SAP-samples/fiori-elements-feature-showcase ?
Sorry, You are right. Yes, your link is the "external" version of the repro. I have also updated my first comment with the correct link now 😉
User | Count |
---|---|
77 | |
30 | |
10 | |
8 | |
8 | |
7 | |
7 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.