You need to sign in to do that
Don't have an account?

soql help plz
Hi All,
I need to get the count of closedcases with an attachments. so for this I tried using following query but no hope.
Select a.Id,a.ParentId From Attachment a where a.ParentId like '500%'
Any help plz
select id, parentId from attachment where parent.type='case'
Thanks Simon,
How to get attachments with Closed Cases only ?
Simon,
I tried below query but i am getting an error.
Select a.Id,a.parentId From Attachment a where a.parent.type ='case' and a.parent.status = 'closed'
It would be helpful to know what your error is
Also since you don't know what the parent is, you can't refer to the Parent.Status since it might not be a Case
I believe this is what causes your error.
Alternatively:
//Yes this method isn't as good, but it's easier.
SELECT (SELECT Id FROM Attachments) FROM Case WHERE Status = 'Closed'
Loop through all and increment a number when the Case.Attachments.size() > 0
Error Message that i get is " Invalid field . NO Such Column Status on entity Name "
Ok, so that means I was right in my guess. Try my alternative, it will work.
But i need get the count of closed cases with attachments in a data loader.I need to email count to my boss.
Would like to elaborate Damein's idea,
run this in system log:
Thanks Rahul.
I am getting an error .System.LimitException: Too many query rows: 50001.Can you please tell me how to fix this error.
You can only query 50k records at once. I had thought there was some workaround to that but I cannot find it right now for some reason.
I believe he wanted the count of Cases that have attachments. In that case it would be more like:
system.debug('====Desired count====='+countAttachments);
As the data is more than 50k records, shift the logic to a batch apex.
Thanks Rahul. Can you help in putting above logic in batch apex.Is it possible to execute batch apex from system log?.I just need the count of cases with attachments.I just need to give the count to my boss.