+ Start a Discussion
SRILAKSHMI BSRILAKSHMI B 

SOQL query retreives deleted record

Hi All,

 

I have the query [Select Id from Email Template where IsActive =true LIMIT 1]. This query is retreving the deleted record and causing problem.Email Template object do not have 'IsDeleted' field to check for the deleted records.

 

 

Please suggest how I can prevent query from retreiving deleted record.

 

Thanks,

Srilakshmi 

SeAlVaSeAlVa

have you tried to add 'AND IsDeleted = False'  to your where clause ?

SalesForce DummySalesForce Dummy

Are you sure the template is deleted? In my org isActive corresponds to the checkbox 'Available For Use' on the template. This just means the template is not available. Have you tried checking that checkbox and seeing if the results of the query changes?

SRILAKSHMI BSRILAKSHMI B

Hi,

 

I have tried IsDeleted= false in the where condition of query but i get No such column error.

 

Please suggest if there is any other way.

 

Thanks,

Srilakshmi B

SalesForce DummySalesForce Dummy

Are you certain that your template is deleted from Salesforce?

SRILAKSHMI BSRILAKSHMI B

In Production a class is failing with the Error  System.Email Exception and Entity is deleted.

 

I just run the same query in dataloader and checked that returns a template.I checked the Id in Instance and got the message entity is deleted.

 

Thanks,

Srilakshmi

Gunners_23Gunners_23

I created a template and deleted it later and ran a query for the templates and didn't return any deleted templated. Even i tried

 

querying from the recycle bin using ALL ROWS as below

 

SELECT ApiVersion,Body FROM EmailTemplate ALL ROWS.

 

I tried the same in both Workbench and Developer Console. So are you sure you got a template which has been deleted?

 

HariPHariP

Hi,

 

I have similar problem. I see deleted records in Recycle Bin, but when I trying to query with ALLROWS or IsDeleted = TRUE, I don't see the deleted records.

 

Is there any setting I need to enable in my org?

 

Thanks

 

hitzhitz
Hi All,

You can not retrive deleted Email Template record via undelete script to get the same you need to log a case in salesforce they have some script. but for other object like Account, contact or any custom object using below script you retrive your deleted record.

Script:
Account objlst = [select id, Name, AccountNumber,isdeleted from Account
                  where id = '001i000000Y7Whx' ALL ROWS ];

Database.UndeleteResult result = Database.Undelete(objlst, false);
il0v3do9il0v3do9

I am having the similar issue. When I query campaignMember object with isDeleted = false, this item comes back, but when I try to delete that object, it throws "first error: ENTITY_IS_DELETED, entity is deleted: []" error.

CampaignMember[] cm = [Select id, campaignId, contactId, Attendance__c from campaignMember where contactId = 'xyz99990' AND isDeleted = false ];
System.debug('cm ' + cm);
delete cm;

Please help!