Write validation rule - salesforce

Write one validation rule in contact object in phone field
First requirement is 10 numbers are mandatory & in 10 numbers first two numbers are between 7-9 and remaining between 0-9 ?

Related

+1 is in front of some cellular numbers how to remove +1

I have cellular phone numbers I need to run query against another table with celluar phone numbers but specific cells in the phone number column have +1 before the phone number and specific cells do not have +1 in front of cellular phone numbers.
Where specific cells in a column have +1 in front of the cellular phone number how to modify by removing +1 if exists.
Usually the cellular phone numbers are 10 digits in length. So, You can select the Phone numbers which are greater than the length of 10 and overwrite those values with the last 10 digits (length_Of_Cell_Value-10 to length_Of_Cell_Value). So that the exact phone number without the country code is overwritten at the respective cell value..

how to write a query with constraint of 'phone number has 4 consecutive digits between 0 and 2 inclusive' in sql

So far i tried doing this, but it is wrong
Phone like '[0-2][0-2][0-2][0-2]'
Right now you check, if the phone number consists only of four digits between 0 and 2. You need to add wildcards if there can be more characters in the phone number.
If the four digits can appear anywhere in the string use:
CHECK (phone LIKE '%[0-2][0-2][0-2][0-2]%')
If they can only appear at the beginning use:
CHECK (phone LIKE '[0-2][0-2][0-2][0-2]%')
If they can only appear at the end use:
CHECK (phone LIKE '%[0-2][0-2][0-2][0-2]')

ng-pattern is not considering if starting number is zero in angularjs

I have to validate the brazil phone no, in brazil phone can be started with zero and it will be 8 digits
I have given <input type="number" name="mobileNo" ng-model="booking.phone" ng-pattern="/^[0-9]{8,8}$/" required placeholder="Phone no">
validation is working fine if i given something like "25869859"
But if i have given as "02587895" it is not counting the first number if it is start with zero, it is taking 9 digits
what is need is it should take only 8 digits even if i given number starting with zero
Try change the Quantifier: ^[0-9]{8,9}$
Quantifier - {8,9} Matches between 8 and 9 times
Or if you want to verify 0, try:
^0?[0-9]{8,8}$
0? matches the character 0 literally between zero and one times, as many times as possible, giving back as needed
Demo

Database storing: pure or encoded?

A simple question. How should I store telephone numbers and e-mail adresses in a database ? Just pure text (or numbers) like email#email.com or is it better to encode it with a key (a bit like how passwords are saved in databases). In that case it becomes unreadable (and much longer) unless you know the key.
The only reason for that would be if someone hacks the databsae, and let's say they are many important e-mails and telephone numbers in the database.
How does, for example, linkedIn and facebook keep all this data?
Telephone numbers are semi-unique Id's. They are not numeric quantities or counts. They can be digits and in some cases alphanumeric, e g. 1-(800)-flowers.
Store the telephone numbers as text as you don't want to add, subtract, multiply or divide them. You can normalize the numbers into county code, and area code and number if there is a need to search by country or area code. An alternative is to provide a functions to access the a telephone number text string and derive the county code and area code.
Another important aspect do you store the format codes ( parens, spaces symbol, or dashes) for the numbers '(123) 456-7890' or do you strip these out and store only digits. If you want to have semi-uniqueness or be able to search for equality then just store the digits. Some numbers are
special codes like '*82' do want to allow these as number as well?
I you wish to derive any intelligence from the telephone number then you should base the number's structure on the text fields based on the North American Numbering Plan https://en.wikipedia.org/wiki/North_American_Numbering_Plan.

Uniquely identify a big number with a smaller one (for data base index)

I have a "fact" transaction table where a ticket has several transactions, each transaction is a registry.
To identify a ticket I have to group the table with 5 fields, (4 numbers and a date) that results in a 22 digit number, but to be able to use it effectively, it needs to be 19 digit max.
The total number of tickets that the table could store is a 10 digit number max.
How can I obtain a <= 19 unique number, from a 22 unique number composed by 5 numbers (including date transformed)?
It sounds like a hash to me, but I dont know much about them, and need it to be unique and numeric.
I think you'll struggle to find a hash function that can take arbitrary (unknown) input data and guarantee you a unique output.
The simplest solution would just be to add an autoincrement field to your table.

Resources