Add Folder Item to Workflow List
- Last UpdatedJun 10, 2024
- 1 minute read
The list internally uses Form engine infrastructure. During list creation, the list columns are defined as form fields. When adding an item, values have to be set for these fields.
For example: The following code example demonstrates how to add a new work flow item to Workflow list. For folder item, the Itemtype value should be 0.
PROCEDURE
Dll REFERENCE
Workflow.NET.NET2
Skelta.forms.core
NAMESPACE USED
Workflow.NET
Skelta.Forms.Core.Controls
Try the following code in a console application by adding the above references and name spaces:
//Creating ListDefinition for specified Repository and List
//Here Application="Repo1" and List="Workflow"
ListDefinition listdef = ListDefinition.GetList(new Skelta.Core.ApplicationObject("Repository2"), "Workflow");
//Creating a new listItem for the given listdefinition.
Skelta.Repository.List.ListItem newListItem = new Skelta.Repository.List.ListItem(listdef);
//Assigning the Title and description for the listitem. ((ListTextDataItem)newListItem.ListForm.Records[0].FindControlByID("_sys_wf_title")).Value = "Folder Name"; ((ListTextDataItem)newListItem.ListForm.Records[0].FindControlByID("_sys_wf_desc")).Value = "Description text";
//For "Folder" item, Itemtype should be 0
newListItem.ItemType = 0;
//Accessing User context created while logging in to Enterprise Console site
UserContext UserCtx = new UserContext();
newListItem.LoggedInUserId = UserCtx.LoggedInUserId;
//Note:User context will be available only when the user logins in the enterprise console. Otherwise //the LoggedInUserID has to be set manually
//Example: newListItem.LoggedInUserId = "activedirectory::John"
//For saving the item under a folder or workflow set the following property
//newListItem.ParentItemId = Guid of the Parent workflow folder/item
//Saving the information in the database.
newListItem.Save();