Create New Version
- Last UpdatedJun 10, 2024
- 1 minute read
The following code sample demonstrates the creation of a new version for a workflow.
PROCEDURE
Dll REFERENCE
Workflow.Net.NET2
Skelta.Forms.Core
NAMESPACE USED
Workflow.NET
Skelta.Repository.List
Skelta.Forms.Core.Controls
Try the following code in a console application by adding the above references and name spaces:
//Namespaces
using Skelta.Repository.List;
using Skelta.Forms.Core.Controls;
using Workflow.NET;
//Class level Variables
//Repository Name
string _applicationName = "MyRepo1";
//This value is fixed for workflow lists
string _listName = "Workflow";
ListDefinition _listDef = ListDefinition.GetList(new Skelta.Core.ApplicationObject(_applicationName), _listName);
//specify path of exported Workflow xml file.
string strData = System.IO.File.ReadAllText(@"c:\ADSQLRep_TestWF_1.xml");
//Id of ListItem to which import the workflow
//This id is obtained from the table SKEWorkflow, value of the column Id corresponding to your //repository name(Application) and workflow (Title).
Guid gid = new Guid("6ffa4b1f-9151-4158-b8b3-6733cf2f63ce");
Skelta.Repository.List.ListItem ListItemChangeVersion = new Skelta.Repository.List.ListItem(_listDef, gid);
ListTableForm listTableForm1 = ((ListTableForm)ListItemChangeVersion.ListForm.Records[0].FindControlByID("_sys_wfdef_form"));
string fileName = (string)((ListTextDataItem)listTableForm1.Records[0].FindControlByID("_sys_wfdef_filename")).Value;
string workflowname = ListItemChangeVersion.Title;
Workflow.NET.Interfaces.IDataHandler DBHandler = null;
Config ConfigObj = new Config(_applicationName);
Workflow.NET.Storage.Staging stg = new Workflow.NET.Storage.Staging(DBHandler);
//Repository name
stg.Update("MyRepo1", workflowname, fileName, strData);
ListItemChangeVersion.LoggedInUserId = " skeltalist::1AA9AA25-92F8-4635-839B-CB029EB95B2F";
// If the provider is Active Directory the format is "activedirectory::user id"
//1AA9AA25-92F8-4635-839B-CB029EB95B2F is userguid of the user admin in skelta list
//setting logged-In userid is mandatory
ListItemChangeVersion.SaveAsNextMajorVersion(); // Can Create new version ListItemChangeVersion.ChangeStatusAndUpdate(ListItemVersionStatus.Published);