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

AVEVA™ Work Tasks

Get Values of Default Field of List

  • Last UpdatedNov 15, 2023
  • 2 minute read

Retrieve values of the list items for the default field 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

ListDataHandler

Methods

  • GetAllListItemsWithDefaultField()

    This method retrieves values of all list items for the default field.

  • GetTopLevelListItemsWithDefaultField()

    This method retrieves values of the top level list items for the default field.

  • GetChildListitemsWithDefaultFieldForValue()

    This method retrieves values of the child level list items for the default field.

  • GetChildListItemsWithDefaultFieldForId(id)

    This method retrieves values of the child level list items for the default field for a specific ID.

  • GetChildListitemsWithDefaultFieldForValue(name)

    This method retrieves values of the child level list items for the default field for a specific name.

Scenario

Create a list called Customers with CustomerId (Int Datatype) configured as the UniqueField and CustomerName configured as the DefaultField. Retrieve the values of the new Properties DefaultField and Unique Field added to the ListDefintion by running the following code.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Skelta.Repository.List;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

string repository = "March 2011";

string list = "Customers";

// Creating ListDataHandler object.

ListDataHandler ldh = new ListDataHandler(repository, list, false);

// Retrieving DefaultField.

string defaultfield = ldh.DefaultField;

// Retrieving UniqueField.

string uniquefield = ldh.UniqueField;

// Retrieving top level list items with DefaultField.

Dictionary<Guid, object> customeritems = new Dictionary<Guid, object>();

customeritems = ldh.GetTopLevelListItemsWithDefaultField();

// Looping through individual items to retrieve them.

foreach (KeyValuePair<Guid, object> customer in customeritems)

{

Guid Id = customer.Key;

string customername = customer.Value.ToString();

}

// Retrieving all list items with DefaultField.

Dictionary<Guid, object> customeritems1 = new Dictionary<Guid, object>();

customeritems1 = ldh.GetAllListItemsWithDefaultField();

// Looping through individual items to retrieve them.

foreach (KeyValuePair<Guid, object> customer in customeritems1)

{

Guid Id = customer.Key;

string customername = customer.Value.ToString();

}

// Retrieving all child items (sub customers) of a specific item (customer) with name John.

object cusotmername = "John";

Dictionary<Guid, object> subcustomeritems = new Dictionary<Guid, object>();

subcustomeritems = ldh.GetChildListitemsWithDefaultFieldForValue(customername);

// Looping through individual items to retrieve them.

foreach (KeyValuePair<Guid, object> customer in subcustomeritems)

{

Guid Id = customer.Key;

string customername = customer.Value.ToString();

}

// Retrieving all child items (sub customers) of a specific item (customer) with Id field.

Guid itemid = new Guid("87B15910-54F8-4F78-9EA5-3E3FD3AD3286");

Dictionary<Guid, object> subcustomeritems1 = new Dictionary<Guid, object>();

subcustomeritems1 = ldh.GetChildListItemsWithDefaultFieldForId(itemid);

// Looping through individual items to retrieve them.

foreach (KeyValuePair<Guid, object> customer in subcustomeritems1)

{

Guid Id = customer.Key;

string customername = customer.Value.ToString();

}

// Retrieving the Item Id for the customer with the name Kevin.

object cname = "Kevin";

Guid KevinId = ldh.GetListItemIdForDefaultField(cname);

}

}

}

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