AnsweredAssumed Answered

Access Node History Content

Question asked by alfsender on Oct 7, 2015
Latest reply on Oct 8, 2015 by muralidharand
Hi All,

I am writing a web-script where I need to copy content from node history and make new version from it.

For example I have node which has version history as 1, 1.1, 1.2, 2.0, 2.1. Now I want to create new version 3.0 using content of version 1.0. I tried using versionHistory but after update when i see content in share it shows as undefined. Below is the code snippet which I am using, please provide your valuable suggestion.

   
var resultNode = search.findNode("workspace://SpacesStore/" + "6e5dabc3-fe8a-4c5e-b470-5c2484720e45");
    var versionHistory = resultNode.versionHistory;
    var majorVersion = 1.0;
    var sourceVersion;
    for (i = 0; i < versionHistory.length; i++) {
        var version = versionHistory;
        if (version.label == majorVersion) {
            sourceVersion = version;
            break;
        }
    }
    var historyNode = search.findNode(sourceVersion.nodeRef);
    var workingCopy = resultNode.checkout();
    workingCopy.content = sourceVersion.content;
    workingCopy.checkin("Major Version", true);



Let me know if you want me to add more information here.

Outcomes