Renaming a document version file in a script

You can rename a document version file using the script provided below.

Script with PublicAPI

Note
Documentation on PublicAPI is available here
Attention
The script below is relevant for ELMA up to 3.12.1 inclusive.

Context variable:

context.Document - variable of the Document type

Namespace:

using EleWise.ELMA.API;
Script:
PublicAPI.Docflow.DocumentVersion.RenameVersionFile(context.Document.CurrentVersion, "renamed", true); //Rename the document version while keeping the file version

Script without PublicAPI

For the script to work correctly, add the following assemblies:

EleWise.ELMA.Documents
EleWise.ELMA.Documents.Docflow

Namespaces:

using EleWise.ELMA.ConfigurationModel;
using EleWise.ELMA.Documents.Models;
using EleWise.ELMA.Model.Common;
using EleWise.ELMA.Model.Entities;
using EleWise.ELMA.Model.Managers;
using EleWise.ELMA.Services;
 
In the example below, a document is stored in the context.Doc context variable, the script changes the name of the current document version file. 

Script text:

context.Doc.Versions.ToList().ForEach(v =>{ //view all the document versions
   if (v.Status == DocumentVersionStatus.Current) //if the version is current
   {
   v.File = v.File.Clone(); 
   v.File.Id = null;
   v.File.Uid = Guid.NewGuid();
   v.File.Name = "renamed.docx"; //change the file name
   v.Save();                                                        
   }
});