Try Now
More in this section

Forums / Developing with Sitefinity / Modify document without versioning?

Modify document without versioning?

2 posts, 0 answered
  1. Bob
    Bob avatar
    10 posts
    18 Apr 2012
    31 Jul 2013
    Link to this post
    Hello fellow posters,

    We are creating a CRM based app using Sitefinity as a framework.  Part of the app requires uploading "attachments" associated with CRM entities.  We have successfully used the API to create, modify, and delete documents as described in the documentation found at:


    However, we would like to know if there is an option to replace (modify) a document without versioning as it seems this is automatic thru the API and not settable at the individual document level.

    This post is on behalf of a fully licensed SF customer.

    Thanks...Bob Baldwin
    Trabon Solutions
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    27 Oct 2016
    05 Aug 2013
    Link to this post

    A document that is already uploaded can be retrieved using sitefinity API and all of its properties changed, I believe you have done this part by taking the sample from this documentation.

    For versioning of the document I suppose you mean that no revision history must be saved for this document when it has been replaced, or some of the document properties (title, url) have been changed. The revision history in sitefinity can`t be disabled and upon every publish operation revision history is created. As the modification of the document will be done trough code the created version can also be modified and removed. This can be done trough VersionManager, here is a sample how to query version and truncate them based on version change creation date or the number of allowed revisions for docuent.
    using Telerik.Sitefinity.Versioning;
    using Telerik.Sitefinity.Versioning.Model;
     LibrariesManager libMan = LibrariesManager.GetManager();
                VersionManager versManager = VersionManager.GetManager();
                IQueryable<Document> docs = libMan.GetDocuments().Where(n => n.ApprovalWorkflowState == "Published");
                var _numOfRevisions = 3;
                foreach (NewsItem newsitem in docs)
                    if (versManager.GetItemVersionHistory(newsitem.Id).Count >= _numOfRevisions)
                        var provider = VersionManager.GetManager().Provider;
                        IQueryable<Change> result = from c in provider.GetChanges()
                                                    where c.Parent.Id == newsitem.Id && c.LastModified < DateTime.Now//.AddMonths(-NumberOfMonths)
                                                    select c;
                        IQueryable<Change> result1 = from c in provider.GetChanges()
                                                     where c.Parent.Id == newsitem.Id && c.LastModified > DateTime.Now//.AddMonths(-NumberOfMonths)
                                                     select c;
                        //leaves only the last 3 versions
                        versManager.TruncateVersions(newsitem.Id, 30000);

    Stanislav Velikov
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered