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
Karthi XaviKarthi Xavi 

Comparing a text with a attachment body

Hi,
I want to compare a text with a attachment that is added to a custom object ex: Word "Test" has to checked whether it is placed in the attachment body. using apex I want to check it using apex, Kindly help me with it.
Thanks,
karthi,
Pankaj_GanwaniPankaj_Ganwani
Hi

You can use Blob.toString() method to convert the Attachment body to string and then do comparison:

Blob body = objAttachment.Body;
if(boby.toString() == 'test')
    //execute the block