In the content version, there is a Last Modified Date that populates both the date and time, so I created a custom field called Last_Modified__c with a field type Date that is set to create only date not time.

Now I need a trigger that populates the last modified date, & not the time in Last_Modified__c based on the LastModifiedDate field in the content version.

trigger updateLastModifiedField on Last_Modified_Date__c (after insert) {
List<ContentVersion> LastModifiedToUpdate = new List<ContentVersion>();
for(Last_Modified_Date__c  cv: Trigger.new){
    if(nt.ParentId != null && nt.ParentId.getSObjectType() == schema.ContentVersion.sObjectType){
        ContentVersion cv=new ContentVersion(Id=cv.parentId,RecentNoteContent__c=cv.Body);


    update LastmodifiedToUpdate;


  • What have you tried so far? Where are you stuck? SFSE is not a code-writing service but can often help you with specific problems (see How to Ask). – David Reed Oct 10 at 14:38
  • 1
    You should edit your question to include that. It's hard to read code in comments (and the length of comments is very limiting). After you copy/paste your code into your question, click the {} button to format it so it shows up nicely. – Derek F Oct 10 at 14:46
  • Thank you for adding your code. We still don't know what your question is. Please edit the body of your post to give a detailed, specific statement of the issue and what you're asking the community. – David Reed Oct 10 at 14:56

Your OP is confusing as the trigger isn't on ContentVersion so I'm assuming that is what you wanted based on your description

trigger updateLastModifiedField on ContentVersion (after insert) {
  List<ContentVersion> cvs = new List<ContentVersion>();
  for(ContentVersion  cv: Trigger.new){
    cvs.add(new ContentVersion (Id = cv.Id,
                                Last_Modified_Date__c = cv.LastModifiedDate.dateGMT()));

  update cvs; 


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.