Renaming a document version file in a script

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

Script without using PublicAPI.

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



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.Dok context variable, the script changes the name of the current document version file. 

Script text:

context.Dok.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
Creating a similar script with PublicAPI
Documentation on PublicAPI is available here

Context variable:

context.Document - variable of the Document type


using EleWise.ELMA.API;


PublicAPI.Docflow.DocumentVersion.RenameVersionFile(context.Document.CurrentVersion, "renamed", true); //Rename the document version while keeping the file version