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
shakila Gshakila G 

How to find a last 10 digit number from the mobile field in Apex class?

Hi All,
I have different mobile filed in lead and Account as well contact. The mobile field may contains start with zero or without Zero. So i want to find only last 10 digits in Apex class. So that I can compare the last 10 digit number with the input values.

LstAct=[SELECT Owner.Email FROM Account where (Phone=:Mobile_No   or Mobile__c=:Mobile_No OR Mobile1__c=:Mobile_No OR Mobile2__c=:Mobile_No OR Phone_Additional__c =:Mobile_No)];

Kindly  give me the suggestion to solve this issue

Thanks,
Shakila
SandhyaSandhya (Salesforce Developers) 
Hi,

You can try something like below
if (LstAct.phone != null ) {
String aphone = LstAct.phone.right(10);
}

Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya