I have a custom filed with number datatype and i have a requirement the the field should always start with 304050 and i have to write a condition that it must always contain 16 digits.

Is is Posible.

Can someone help me on this?

Best Regards, Ankita

  • Have you tried using validation rules?
    – Saroj Bera
    Jul 10 '15 at 9:10
  • I tried but i am not able to get it right Jul 10 '15 at 9:17
  • Ankita, you would paste your code here for better help.
    – Ashwani
    Jul 10 '15 at 9:24
  • NOT(REGEX(Card_Number__c, "\\D*?(\\d\\D*?){16}")) This is working now .. now i have to make sure that it always starts with 304050 Jul 10 '15 at 9:30

Ashwini's answer is correct with small change......

LEFT(TEXT(field__c),6) != '304050', 
LEN(TEXT(field__c)) != 16 

You can try something similar like this in validation rule using three functions (OR, LEFT, LEN):

      (LEFT(field__c,6) != '304050',
      LEN(field__c) != 16

Solution is for your hint purpose. may not be 100% correct.

  • Thanks..this is working if i have a text field ..but i have a number field and i cannot risk user entering text after 304050 Jul 10 '15 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.