1

I have a issue where in our Org, last name of many contacts has been changed to Numeric.

I need to take an extract of all those contacts having number in their last name along with their ID.

I tried searching through the forum and tried multiple queries including isNumeric(Column) etc but it is not working.

  • can you add more details on how you are trying to achieve this? code, if any ? – glls Feb 2 '18 at 16:47
  • as i wrote, i tried with IsNumeric(LastName) in query which gave aggregate error. Also tried with strings but it did not parse. – Pankaj Gupta Feb 2 '18 at 16:59
3

The SOQL for this is a bit convoluted, so I'd recommend using a formula, then you can easily make a query for it.

The formula is a checkbox return type:

ISNUMBER(LastName)

And the query simply becomes:

SELECT Id, LastName FROM Contact WHERE Last_Name_Is_Numeric__c = TRUE

Without a formula, you end up having to write something like this:

SELECT Id, LastName FROM Contact
WHERE LastName LIKE '%0%' OR
      LastName LIKE '%1%' OR
      LastName LIKE '%2%' OR
      LastName LIKE '%3%' OR
      LastName LIKE '%4%' OR
      LastName LIKE '%5%' OR
      LastName LIKE '%6%' OR
      LastName LIKE '%7%' OR
      LastName LIKE '%8%' OR
      LastName LIKE '%9%'
| improve this answer | |
  • Age old strategy for augmenting SOQL. – Adrian Larson Feb 2 '18 at 16:48
  • 1
    Also if the numeric last names all start with a number, you could use something like WHERE LastName >= '0' OR LastName <= '999999999'. – Charles T Feb 2 '18 at 18:20

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.