You need to sign in to do that
Don't have an account?
moverdorf
Get ActivityHistories/OpenActivities For A Contact
Hi,
Simply put, I want to retieve any OpenActivites and ActivityHistory rows for a passed Contact.id
My page is passed in the Contact's ID, I then:
I know I can't Select directly on the OpenAcivites/ActivityHistories objects... So I have something like this
SELECT id,(SELECT Who.name,What.name, payout__Category__c,ActivityDate FROM ActivityHistories Order by ActivityDate desc),(SELECT ActivityDate,who.name,what.name FROM OpenActivities Order by ActivityDate desc)
FROM Account Where Id in (SELECT Accountid from Contact where id = '003A000000MI9SJ')
But this is NOT the correct query, because I am bringing back ALL OpenActivities/ActivityHistories for the ACCOUNT and not for JUST the Contact of that account. So how do I change my query so I just get the OpenActivities/ActivityHistories for the one Contact.id.
Thanks.
Simply put, I want to retieve any OpenActivites and ActivityHistory rows for a passed Contact.id
My page is passed in the Contact's ID, I then:
I know I can't Select directly on the OpenAcivites/ActivityHistories objects... So I have something like this
SELECT id,(SELECT Who.name,What.name, payout__Category__c,ActivityDate FROM ActivityHistories Order by ActivityDate desc),(SELECT ActivityDate,who.name,what.name FROM OpenActivities Order by ActivityDate desc)
FROM Account Where Id in (SELECT Accountid from Contact where id = '003A000000MI9SJ')
But this is NOT the correct query, because I am bringing back ALL OpenActivities/ActivityHistories for the ACCOUNT and not for JUST the Contact of that account. So how do I change my query so I just get the OpenActivities/ActivityHistories for the one Contact.id.
Thanks.
SELECT id,(SELECT Who.name,What.name, payout__Category__c,ActivityDate FROM ActivityHistories Order by ActivityDate desc),(SELECT ActivityDate,who.name,what.name FROM OpenActivities Order by ActivityDate desc)
FROM Account Where Id in (SELECT Accountid from Contact where id = '003A000000MI9SJ') and whoId in (SELECT Id from Contact where id = '003A000000MI9SJ')
FROM Account Where Id in (SELECT Accountid from Contact where id = '003A000000MI9SJ')
and who.Id in (SELECT Id from Contact where id = '003A000000MI9SJ')
resulted in an error:
and who.Id in (SELECT Id from Contact
^
ERROR at Row:3:Column:5
Didn't understand relationship 'who' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
SELECT id,(SELECT Who.name,What.name, payout__Category__c,ActivityDate FROM ActivityHistories Order by ActivityDate desc),(SELECT ActivityDate,who.name,what.name FROM OpenActivities Where who.Id = '003A000000MI9SJ' Order by ActivityDate desc)
FROM Account Where Id in (SELECT Accountid from Contact where id = '003A000000MI9SJ')