3

The scenario is there is a document library where user maintains major and minor versions of a document. When the user has to edit a document s/he checks out the document and starts their editing. When they think there editing is large enough they check-in back the document to the library as a major version. I want to display that check-in date column in the library.

I read some post and they mentioned that published date equals to modified date. But I believe that modified date could be anything when you do a minor change. For example, there is a responsibility column in document library if you change the person name there, SharePoint takes it as modification and update 'modified' column with the new date. Whereas I want the published date of the documents.

Is there any way to do this. I will really appreciate your help.

2 Answers 2

3

You are right that the Modified date applies to any change, such as a change to just metadata. So if you want to have a date field that is specific to when a document was checked in as a major version, you will have to either create a custom Calculated Column or use a generic date column and have users manually edit the date when the changes made are to publish a new major version and not just make minor changes.

2
  • Thanks @hoffie4 for replying. Could you please give me some idea how the calculated column can work? Commented Oct 24, 2016 at 16:19
  • 1
    Calculated Column will not work either, as it will update for every metadata change as well Commented Oct 25, 2016 at 9:56
4

You can't use modified data as it will have the date for every metadata change. This may seem like an overkill for such a simple requirement, but I think you will need to write custom C# code using event receiver attached to list which will update a custom date/time column with the published date value if you want automation . Something as mentioned in below code:

public  override  void  ItemUpdating(SPItemEventProperties  properties)
        {
            base.ItemUpdated(properties);
            using  (DisabledEventsScope  scope = new  DisabledEventsScope ())
            {
                SPListItem  listItem = properties.ListItem;
//add logic to check if the file version is major version or not and if its 
//major version , update the date column as below:
                int iBefore = (int.TryParse(properties.BeforeProperties["vti_level"].ToString(), out iBefore) ? iBefore : -1);
                int iAfter = (int.TryParse(properties.AfterProperties["vti_level"].ToString(), out iAfter) ? iAfter : -1);
                if(iAfter!=iBefore)
                {
                  listItem["PublishedDate"] = DateTime.Now; //change the column name as per your date column. Here, PublishedDate is a custom date/time column
                  listItem.Update();
                }
            }
        }

Reference - Identify Publish a Major Version in event receiver

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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