You need to sign in to do that
Don't have an account?
Brian Shea
Concatenate a zero to the start of a string in APEX/SOQL
Hi there,
I have a custom zip code field (text field) in my application and when I recently loaded a large volume of data, I the leading zero on a few hundred of the zip codes were dropped.
I have written a SOQL query that identifies all of the records that I want to fix:
SELECT Name, Physical_Address_Zip_Code__c FROM Location__c WHERE NOT Physical_Address_Zip_Code__c LIKE '_____' ORDER BY Physical_Address_Zip_Code__cbut I want to write an apex script that concatenates a leading zero to the start of all these records. Anyone know how to do this? Thanks!
You can use for loop to iterate over the list of record and upande 0 to Physical_Address_Zip_Code__c.
For example:
Hope it will help you.
Thanks
All Answers
You can use for loop to iterate over the list of record and upande 0 to Physical_Address_Zip_Code__c.
For example:
Hope it will help you.
Thanks
That worked great. Thank you!
The only edit I made to your code was to update the WHERE clause from:
back to my original condition:Thanks for your help Shweta!