function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DanielBDanielB 

REST API - Attachments of Task/Event objects returning null parent fields

In my application I retrieve attachment parent information with the following query:

 

SELECT id, parent.id, parent.name, parent.type FROM Attachment WHERE parent.type = 'xxxx'

 

However, when I execute this same query for Task or Event object types:

 

SELECT id, parent.id, parent.name, parent.type FROM Attachment WHERE parent.type = 'Task'

 

I get attachment objects but the 'Parent' field is null. This query works for every other object type, so it doesn't look like this is expected behavior. The 'parent.type' variable seems to be available because the WHERE clause correctly filters the results, but that same field is returning null in the query result.

 

Has anyone been through this issue before? Can anyone confirm this is not a problem with my Salesforce environment?

Vinita_SFDCVinita_SFDC

Hello,

 

Please let me know if query is returning null only for parent ID or for parent name as well. If this is so please make sure there are attachments in Tasks, as Tasks/Events are supported for ParentID.

 

Reference: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_attachment.htm

DanielBDanielB

Thanks for your response,

 

I have three attachments, each attachment is in a different task object. The following query returns three attachments with unique Task ids:

 

SELECT id, parentId FROM Attachment WHERE parent.type = 'Task'

 

However this next query returns three attachments with null parent fields (parent name, parent id and parent type):

 

SELECT id, parent.id, parent.name, parent.type FROM Attachment WHERE parent.type = 'Task'

 

I'm trying to obtain the parent name but it seems this does not work for Task and Event objects. This query works for all other object types.

DanielBDanielB

Has anyone been through this or can anyone confirm this is happening in their salesforce account as well?

Andrew McGrathAndrew McGrath
A bit late but was there a resolution to this? I get the same error running something like select id, parent.id from attachment
where parent.type = 'Task'