Activity Forums Salesforce® Discussions How to extract the file extension into an custom field?

  • Abhinav

    Member
    July 21, 2016 at 8:56 am

    Hi Tanu,

    Here is the sample code :-

    List<Attachment> attach = [SELECT Name FROM Attachment];
    for(Attachment a : attach){
    String nameField = a.Name;
    if(nameField.Contains('.'))
    system.debug(nameField.substringAfter('.'));
    }

    I hope this helps.

  • Shekhar Gadewar

    Member
    July 21, 2016 at 1:06 pm

    Hi Tanu,

     

    U can try : lastIndexOf() function

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos