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
SirishaMSirishaM 

Soql Query on Attachment..Please help..

Hi ,

I wrote the folowing SOQL query on Attachment
Code:
for(Attachment attms: [select LastModifiedDate from Attachment where parentId= :asub.Id])
if(attms.LastModifiedDate < asst.Due_Date__c)
{
delete attms;
}

 Where asub and asst are my Custom objects. I am checking if the attachment is added after the deadline and then I delete the attachment if it is .

I did this because I can  not check the deadline before attaching the file.

My problem is it is does not do this . Even though the apex class gets saved with out any error. It does not delete the file based on the condition.

Kindly help where I am going wrong..

Sirisha