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
enrydevenrydev 

Return with Soql query “Related Content”

I'm trying to write a soql query to get all the content's ids of the related content on a custom object.

I would like to know which are the related content of a record. 

 

I have tried with Schema Explorer but have access to related content informations looks impossible.

Is it possible?

Thanks in advantage for any advice.

BR

souvik9086souvik9086

Can you be a little more clear in your explanation?

Did you want to get all the child ids of a partcular parent record?

Please explain us more

 

Thanks

enrydevenrydev

 

On my custom object record i'm adding related content files, they are showed in a related list on the page layout.This is a standard  Salesforce feature that let you add Content Files to your record.

 

I want create a visual force page with that related list.But In my controller i'm not able to write the soql query to get all the ids of the salesforce content files for a certain record.

 

Thanks for your time.

souvik9086souvik9086

This will be your query

 

CustomObject__c obj = [SELECT ID,Name, (SELECT ID,Name from ContentFiles__r) FROM CustomObject__c WHERE id = :customObjectRecordId];

 

Use obj.ContentFiles__r in your visualforce page pageblocktable value.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

enrydevenrydev

I've tried the following query in the developer cosole

SELECT ID,Name, (SELECT ID,Name from ContentFiles__r) FROM Software_Downloads__c

 i get this error:

ID,Name, (SELECT ID,Name from ContentFiles__r) FROM Software_Downloads__c
                              ^
ERROR at Row:1:Column:38
Didn't understand relationship 'ContentFiles__r' in FROM part of query call. 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.

 

 

Thanks again.

souvik9086souvik9086

Make sure that the name of the object is ContentFile__c, then in the child relationship you can write ContentFiles__r.

Another thing ContentFile is the child object of Software_Downloads__c, right?

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

enrydevenrydev

Content file isn't a custom object(ContentFile__c). I guess there is a standard object to store Content files related to a custom object.

But this is a standard  salesforce functionality; let you add files (stored in Content) to a record .

 

Thanks a lot!

souvik9086souvik9086

Please find the name of the object and write its plural form there.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

enrydevenrydev

This is the problem , i' don't find where are stored the related content.

 

This is a related question:

Question