Delete List Item by Validating Security
- Last UpdatedApr 02, 2024
- 1 minute read
Check and delete 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, delete 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.DeleteListItem("SkeltaRepo", "Employee", "admin");
}
private void DeleteListItem(string applicationname, string listname, string LoggedInUser)
{
// Creating ListDefinition Object.
ListDefinition userlist = new ListDefinition(new Skelta.Core.ApplicationObject(applicationname),
listname);
// Creating ListItem object.
ListItem listitem = new ListItem(userlist, new Guid("cead17b3-d91d-42d2-ac00-da0ccd1e3611"));
// Checking whether list item can be deleted.
if (listitem.CanDelete())
{
// Deleting list item.
listitem.Delete();
Console.WriteLine("ListItem has been successfully deleted");
}
else
{
Console.WriteLine("Can not delete ListItem");
}
}
}
}
}