+ Start a Discussion
Data Migration 5Data Migration 5 

how to extract the file extension into an custom field

I have a custom field that stores complete file name. Is there any way to extract the file extension (like .ppt,.pdf etc) and populate the extension in another custom field?
GauravTrivediGauravTrivedi
You can use this 
List<Attachment> ata= [SELECT Name FROM Attachment];
for(Attachment a : ata){
    String nameField = a.Name;
    if(nameField.Contains('.'))
    	system.debug(nameField.substringAfter('.'));
}

Let me know if your problem is resolved.
rkris320rkris320
This helped me. thanks