2

for (SObject deletedObject : [SELECT Id, isDeleted, LastModifiedDate, parentId FROM Attachment WHERE isDeleted = true AND LastModifiedDate >= :timestamp ALL ROWS]) {

It appeared, that recently more than 50000 of Notes & Attachments were deleted. The trick is that all of them don't relate to my application - they wasn't linked to 'my' custom objects. I'm wondering, is there any way, I can query Notes & Attachments for specific sObjects?

  • Isn't the FROM clause working for you here? And what is the value in var "obj"? – Jagular May 4 '15 at 14:00
  • Can you please dump your query without all the string concatenation? It is quite hard to read. – Adrian Larson May 4 '15 at 14:28
4

It can be done. Here is some documentation on how it works. See the "Using the Type qualifier" section. This qualifier does not require polymorphism to be enabled in the org.

SELECT Id FROM Attachment WHERE Parent.Type = 'My_Object__c'

or

SELECT Id FROM Note WHERE Parent.Type = 'My_Object__c'
  • N.B. sadly (as of V41), this does not work: select id from FeedComment where Parent.Type = 'Account' - see workaround – cropredy Jan 12 '18 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.