function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael MMichael M 

Query based on character towards end of external id

Hello, on one of our custom objects, we have a custom external id field. We want to change the format of the field, so we need to either query the records with workbench and then re-import them, or build a report and add a column then import that. The current format for the external id field is name + Date of Birth. So the only thing that all of the records that we want to update have in commin is that the 3rd to last charachter is "-". (E.g. 'Tom Jones1999-09-09'). How can I write a query to fetch all records where the 3rd to last character is a "-"? 
Best Answer chosen by Michael M
ShirishaShirisha (Salesforce Developers) 
Hi Michael,

Greetings!

I don't think we have any direct way to query to pull the records based on the position of the string.However,we can split the string and store the "-" in one variable and based the variable we can query.

reference:

https://developer.salesforce.com/forums/?id=9060G000000MUERQA4

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri