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
Jonathan Wolff 7Jonathan Wolff 7 

Create a class to populate a custom field with latest ContentDocumentId

Hello, I want to ave an apex class/trigger, that populates a custom field on my record with the contentdocumentId of the latest uploaded record. Is there any possibility?
I would be glad if you could show me a code sample.

Greetings
Jonathan
AnkaiahAnkaiah (Salesforce Developers) 
Hi Jonathan,

Custom field is on which object ?

whenever new contentdocument attached you need to populate the id value in custom field?

Thanks!!
Jonathan Wolff 7Jonathan Wolff 7
Hi Ankaiah,
its for my custom Mediathek__c object and it should populate the contentdocument id in a field. It could be after a new document is attached, but i already uploaded many documents so it would be nice to get the Id of the last attached :)

Thank you very much.
Greetings
Jonathan