Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

In our email to case functionality, we plan to introduce a feature via which the users will be able to input the Legacy Account Id which is numeric along with the Salesforce Account Id which is alphanumeric.

Is there any method available in Saleforce library that can indicate whether the data is a string or number ?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Yes. The Salesforce dev guide has a bunch of String methods for this kind of stuff.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm#apex_System_String_methods

Methods of interest are:

  1. isAlpha()
  2. isAlphanumeric()
  3. isNumeric()
share|improve this answer

The String class had isNumeric(), isAlpha() and a number of other methods for checking the contents of Strings added in Winter '13.

The documentation for these methods can be found here :

isNumeric()

Returns true if the current String contains only Unicode digits; otherwise, returns false.

isAlpha()

Returns true if all characters in the current String are Unicode letters only; otherwise, returns false.

Example usage:

String num = '123';
System.debug(num.isNumeric()); // Writes TRUE to the debug log
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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