Is there a way(regex or something) to find out if a given string is a Salesforce Id or not? I'm looking for some helper class in Java.
Tell me more
×
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.
|
Regex is okay:
If you use |
||||
|
|
|
Apex Id data type does validate what is set into it, In apex, you could assign a string to an Id type variable. If you put that in a try block and catch StringException the catch block will indicate failure.
EDIT: If you wanted to access that logic from outside of SFDC, you could write the logic into a custom webservice method. Even though this is a very clean way to do Id datatype checking, it has the downside of consuming a webservice call for very little gain. But it could be scaled perhaps to do the same with an array of strings:
|
|||||||||||||||||||
|
