Save ListItem
- Last UpdatedMay 07, 2026
- 2 minute read
Save a ListItem using list API.
The list API makes use of the following DLL references, namespaces, classes, and methods.
|
DLL Reference |
Namespace |
|---|---|
|
|
|
Class |
|---|
|
|
Methods |
|---|
|
Scenario 1
For the Employee list mapped to an Emp table with the fields such as Title, Name, City, State, Pincode, and Age, save the ListItem by running the following code.
using System;
using Workflow.NET;
using Workflow.NET.Engine;
using Skelta.Forms.Core.Controls;
using Skelta.Repository.List;
public class WorkflowScript0144412702584f2a8852a95a0a727737
{
public string Run(int ExecutionId, int ExecutionDetailsId, Workflow.NET.Engine.Context ctx, Workflow.NET.Action action, string inlink)
{
string applicationname = ctx.ApplicationName;
string listname = "Employee";
ListDefinition lstdef = new ListDefinition(new Skelta.Core.ApplicationObject(applicationname), listname);
Skelta.Repository.List.ListItem listItem = new Skelta.Repository.List.ListItem(lstdef);
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("Title"))).Value = "T3";
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("Name"))).Value = "A3";
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("City"))).Value = "C3";
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("State"))).Value = "S3";
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("PinCode"))).Value = "P3";
((ListIntDataItem)(listItem.ListForm.Records[0].FindControlByName("Age"))).Value = "20";
listItem.Save();
return "saved";
}
}
Update an existing item
To update an existing item, use the same ListItem API used for saving a new item.
The only difference is that while creating the ListItem object, you must provide the
ID of the existing item to be updated. For example:
Skelta.Repository.List.ListItem listItem = new Skelta.Repository.List.ListItem(lstdef, new Guid("<ItemId>"));
Scenario 2
If we add a new column to the Emp Table say Department, then we need to call the ClearTableNameKeyFromTableCollection API before calling the listitem.save().
Skelta.Core.DS.SingleTableObject.ClearTableNameKeyFromTableCollection(ctx.DataHandler.DataSourceType, applicationname, "EmpTable");
using System;
using Workflow.NET;
using Workflow.NET.Engine;
using Skelta.Forms.Core.Controls;
using Skelta.Repository.List;
public class WorkflowScript0144412702584f2a8852a95a0a727737
{
public string Run(int ExecutionId, int ExecutionDetailsId, Workflow.NET.Engine.Context ctx, Workflow.NET.Action action, string inlink)
{
string applicationname = ctx.ApplicationName;
string listname = "Employee";
Skelta.Core.DS.SingleTableObject.ClearTableNameKeyFromTableCollection(ctx.DataHandler.DataSourceType, applicationname, "Emp");
ListDefinition lstdef = new ListDefinition(new Skelta.Core.ApplicationObject(applicationname), listname);
Skelta.Repository.List.ListItem listitem = new Skelta.Repository.List.ListItem(lstdef, new Guid("cead17b3-d91d-42d2-ac00-da0ccd1e3611"));
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("Title"))).Value = "T3";
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("Name"))).Value = "A3";
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("City"))).Value = "C3";
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("State"))).Value = "S3";
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("PinCode"))).Value = "P3";
((ListIntDataItem)(listItem.ListForm.Records[0].FindControlByName("Age"))).Value = "20";
((ListTextDataItem)(listItem.ListForm.Records[0].FindControlByName("Department "))).Value = "R&D";
listItem.Save();
return "saved";
}
}