Change version manually?

Showing results for 
Search instead for 
Did you mean: 
Active Member

Change version manually?

Hi! It seems to be hard to change the version number by executing a script. Is there things i need to do before? My code is the following:

var refName =["cm:name"];
var refFile = companyhome.childByNamePath(refName);;;;

var logFile = space.childByNamePath("log.txt");
if (logFile==null)
   var logFile = space.createFile("log.txt");
if (logFile!=null)
   logFile.content+= "\n\r" + " Version refFile" + + " Version document " +;

What the script is supposed to do is to take the version from a file under Company Home which has the same filename as the file that is referred to as "document". The logfile gives this output:

              Version refFile1.1 ref Version document 1.1

Which indicates that the version is updated to 1.1 but in the browser it's still 1.0. I have tried to make to following change in contentModel.xml:
      <aspect name="cm:versionable">
            <property name="cm:versionLabel">
               <title>Version Label</title>

But without any success.

2 Replies
Member II

Re: Change version manually?

You could try to remove the aspect, change it and readd it.  This has worked for me with custom aspects when just reassigning a value didn't work:

var oldVersion =[cm:versionLabel];
/*increment however you see fit*/
var props = new Array(1);
props["cm:versionLable"] = newVersion;
document.addAspect("cm:versionable", props);

No guarantees, though.
Active Member

Re: Change version manually?

Thanks for you reply! But it didn't work even though i tried your suggestion. Fortunately, however, i managed to find out what i needed to do. After i set;
it worked. It looks like the version property becomes static and not automatically set. It even seems impossible to check out the document afterwards but luckily i don't need that in this case.