+ Start a Discussion
tengeltengel 

Retrieve ID of record's most recently posted Chatter File

I have a custom object called Producer_Commission_Report__c. Each of these records will have one (1) Chatter file posted to them.

 

I would like to populate a field on this object called "Chatter File ID" with the ID of the most recently (i.e., the only) posted Chatter File on each record. Can anyone offer some help?

Vinita_SFDCVinita_SFDC

Hello,

 

For this write apex code where you will fetch the ID of the file in a query and assign this id to Producer_Commission_Report__c.

 

You can query like: SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = '[RECORD ID]'