Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

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

  • System

  • Skelta.Repository.List

Class

  • Skelta.Repository.List.ListDefinition

  • Skelta.Repository.List.ListItem

Methods

  • ListItem.CanChangeStatus (ListItemVersionStatus)

    This method checks whether you can change the status of a list item, and returns a Boolean value.

  • ListItem.ChangeStatusAndUpdate(ListItemVersionStatus)

    This method changes the status of a list item and updates the list item.

Scenario

For the Employee Details list mapped to an Employee table with the fields such as TitleNameAgeSalaryDepartment, 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");

}

}

}

}

}

Related Links
TitleResults for “How to create a CRG?”Also Available in