You need to sign in to do that
Don't have an account?
Michael M
SOQL query on feeditem's parent's custom fields
Hello, I need to query a feeditem's parent's custom field.
Here is so far:
Discharge__c discharge=[Select Id, Name, Date_of_Birth__c from Discharge__c where Id = :this.dis.id];
listofNotes = [SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Parent.Name, Body
FROM feeditem
WHERE Parent.Name = :discharge.name ];
I need to add another WHERE clause stating that the Parent (discharge record's) date of birth is = discharge.date_of_birth__c
Is this possible?
Here is so far:
Discharge__c discharge=[Select Id, Name, Date_of_Birth__c from Discharge__c where Id = :this.dis.id];
listofNotes = [SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Parent.Name, Body
FROM feeditem
WHERE Parent.Name = :discharge.name ];
I need to add another WHERE clause stating that the Parent (discharge record's) date of birth is = discharge.date_of_birth__c
Is this possible?
ParentId in FeedItem is a Polymorphic Field associated with dozens of objects.
Name is an exception among the fields because it belongs to all the linked objects here.
Unfortunately, BirthDate from Contact is not allowed in the filter part of the request but just in the select part.
And you cannot use WHERE Parent.Name = :discharge.name either but its equivalent only: ParentId ='0030Y00000AMgxNQAT'
- TYPEOF is only allowed in the SELECT clause of a query. You can filter on the object type of a polymorphic relationship using the Type qualifier in a WHERE clause, see Filtering on Polymorphic Relationship Fields for more details.
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_and_polymorph_keys.htmTherefore, there is a list of Feed items that is browsed to verify the birthdate.
All Answers
I suspect your query is answered in this blog,
https://salesforce.stackexchange.com/questions/148079/how-to-get-custom-object-with-related-item-feed-in-soql
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks.
ParentId in FeedItem is a Polymorphic Field associated with dozens of objects.
Name is an exception among the fields because it belongs to all the linked objects here.
Unfortunately, BirthDate from Contact is not allowed in the filter part of the request but just in the select part.
And you cannot use WHERE Parent.Name = :discharge.name either but its equivalent only: ParentId ='0030Y00000AMgxNQAT'
- TYPEOF is only allowed in the SELECT clause of a query. You can filter on the object type of a polymorphic relationship using the Type qualifier in a WHERE clause, see Filtering on Polymorphic Relationship Fields for more details.
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_and_polymorph_keys.htmTherefore, there is a list of Feed items that is browsed to verify the birthdate.