Update List Item by Validating Security
- Last UpdatedApr 02, 2024
- 1 minute read
Check and update a list item using the list API.
The list API makes use of the following DLL references, namespaces, classes, and methods.
|
DLL Reference |
Namespace |
|---|---|
|
Workflow.NET.NET2 |
|
|
Class |
|---|
|
|
Methods |
|---|
|
Scenario
For the Employee Details list mapped to an Employee table with the fields such as Title, Name, Age, Salary, Department, and Manager, update list item by running the following code.
using System;
using Skelta.Repository.List;
namespace ListObject
{
public class DynamicList
{
static void Main(string[] args)
{
DynamicList DL = new DynamicList();
DL.UpdateListItem("SkeltaRepo", "Employee", "admin"); }
private void UpdateListItem(string applicationname, string listname, string LoggedInUser)
{
// Creating ListDefinition Object.
ListDefinition userlist = new ListDefinition(new Skelta.Core.ApplicationObject(applicationname), listname);
Guid listitemguid = new Guid("cead17b3-d91d-42d2-ac00-da0ccd1e3611");
// Creating ListItem Object.
ListItem listitem = new ListItem(userlist, listitemguid);
// Checking whether list item can be updated.
if (listitem.CanChangeStatus(ListItemVersionStatus.Published))
{
// Updating list item.
((ListTextDataItem)(listitem.ListForm.Records[0].FindControlByName("Name"))).Value = "ken smith";
listitem.ChangeStatusAndUpdate(ListItemVersionStatus.Completed);
Console.WriteLine("ListItem has been successfully Updated");
}
else
{
Console.WriteLine("Can not update ListItem");
}
}
}
}
}