You need to sign in to do that
Don't have an account?
Rakesh K 60
WhoId is returning null in SOQL and not shown in Apex
Hi,
I'm writing an Apex class to retrieve the Activity History and in the result there is No WhoId, but able to see WhatID. My Apex API Version is 49(Also tried with 48 resulting the same). Here is my Code.
When I run this, here is my Sample Output.
When I tried the Same in QueryEditor, In the output, WhoId is Shown as null. (to be simple, I got rid of the unnecessary fields).
here is my SOQL
Finally, I ran the query on the object(Task in current case) with the ID that is returned by OpenActivities, To my Surprise I'm able to see the result there. Here is my final SOQL.
And here is my output.
I'm a bit confused about where am I going wrong. I'm running as System Admin. Please let me know how can I fix this.
Thanks
I'm writing an Apex class to retrieve the Activity History and in the result there is No WhoId, but able to see WhatID. My Apex API Version is 49(Also tried with 48 resulting the same). Here is my Code.
Map<String, List<sObject>> finList = new Map<String, List<sObject>>(); Account acc = [SELECT Id, Name, (SELECT Id, Subject, ActivityDate, WhatId, What.Name, WhoId, Who.Name, ActivitySubType FROM OpenActivities order by ActivityDate desc) FROM Account WHERE Id = '0012x000004g9gSAAQ']; finList.put('actCur', acc.OpenActivities); System.debug(finList.get('actCur'));
When I run this, here is my Sample Output.
When I tried the Same in QueryEditor, In the output, WhoId is Shown as null. (to be simple, I got rid of the unnecessary fields).
here is my SOQL
SELECT Id, (SELECT Id, WhatId, WhoId FROM OpenActivities order by ActivityDate desc) FROM Account WHERE Id = '0012x000004g9gSAAQ'And here is the output.
Finally, I ran the query on the object(Task in current case) with the ID that is returned by OpenActivities, To my Surprise I'm able to see the result there. Here is my final SOQL.
Select WhoId, Who.Name from Task where ID='00T2x000006jnJJEAY'
And here is my output.
I'm a bit confused about where am I going wrong. I'm running as System Admin. Please let me know how can I fix this.
Thanks
Can you try with the PrimaryWhoId field from OpenActivities?
A similar question was posted here
Anudeep