+ Start a Discussion

Soql Query on Attachment..Please help..

Hi ,

I wrote the folowing SOQL query on Attachment
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..