You need to sign in to do that
Don't have an account?
Gabriel Costa 13
Get Images and Media related to an object SOQL
Hi,
I have a 'Property' object that has some images and other media attached to it. How can I get the images/files associated with this object in SOQL?
This is the section where the files are stored
I have a 'Property' object that has some images and other media attached to it. How can I get the images/files associated with this object in SOQL?
This is the section where the files are stored
A similar ask was posted here https://salesforce.stackexchange.com/questions/22978/soql-query-for-retrieving-images-from-notes-and-attachments
Example:
If this information helps, please mark the answer as best. Thank you
All Answers
A similar ask was posted here https://salesforce.stackexchange.com/questions/22978/soql-query-for-retrieving-images-from-notes-and-attachments
Example:
If this information helps, please mark the answer as best. Thank you
I've used SOQL as you mentioned in the endpoint below but I'm getting 0 results even having files attacheds. Is there any other object that stores the media data?
https://MYORG.my.salesforce.com/services/data/v56.0/query?q=SELECT FIELDS(ALL) FROM Attachment WHERE Name!='log.txt' LIMIT 200
https://MYORG.my.salesforce.com/services/data/v56.0/query?q=SELECT FIELDS(ALL) FROM pba__PropertyMedia__c WHERE pba__Property__c='ID' LIMIT 200
Thanks for your answer Swenta, it guided me to the right answer.
Here is an example of a SOQL query that retrieves all the images associated with a 'Property' object:
SELECT ContentDocument.Title, ContentDocument.FileType, ContentDocument.LatestPublishedVersion.Id
FROM ContentDocumentLink
WHERE LinkedEntityId = 'Property_Id'
In this query, you need to replace the Property_Id with the actual Id of the 'Property' object that you want to retrieve the images for.
You can also use different fields of ContentDocument and ContentVersion to filter and retrieve the specific media files that you need.
Please note that it is not possible to directly query the ContentDocument object. You have to use the ContentDocumentLink to get the related documents.
Additionally, you can use the ContentVersion object to retrieve the version information of the media files and use it to sort or filter the results.
It is important to note that in a query, you can only get the files that are shared with the user who runs the query. you can use the sharing settings to share the files with users or groups that need to access them.