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

AVEVA™ Work Tasks

Create ListItem

  • Last UpdatedJun 10, 2024
  • 1 minute read

The following code sample demonstrates the creation of a list item in the Workflows list.

PROCEDURE

Dll REFERENCE

Skelta.Forms.Core.dll

Workflow.Net.NET2.dll

NAMESPACE USED

Skelta.Repository.List

Skelta.Forms.Core.Controls

Workflow.NET

Create a console Application and execute the following code:

To create a listitem, follow the steps below:

  1. Create an object (_listDef) of ListDefinition Class by passing application name and listname or Guid.

  2. Create an object (_listItem) of ListItem class by passing ListDefinition object (_listDef).

  3. Find the control named "_sys_wf_form" in the ListItem object (_listItem) and set to ListMainForm object (_listMainForm). Do the proper casting.

  4. Set the "_sys_wf_title", _sys_wf_desc" controls value properties of ListMainForm object (_listMainForm). Do the proper castings.

  5. Find the control named "_sys_wfdef_form" in the ListItem object(_listItem) and set to ListTableForm object (_listTableForm) . do the proper casting.

  6. Set the "_sys_wfdef_filename","_sys_wfdef_productionid" controls value properties of ListTableForm object (_listTableForm). Do the proper castings.

  7. Set the "LoggedInUserId" property of ListItem object (_listItem) to logged-In userid.

  8. Finally call the save method of ListItem object (_listItem).

    //Namespaces

    using Skelta.Repository.List;

    using Skelta.Forms.Core.Controls;

    using Workflow.NET;

    //Class level Variables

    // Repository Name

    string _applicationName = "MyRepo1";

    // This value is fixed for workflow lists

    string _listName = "Workflow";

    ListDefinition _listDef;

    _listDef = ListDefinition.GetList(new Skelta.Core.ApplicationObject(_applicationName), _listName);

    Skelta.Repository.List.ListItem _listItem = new Skelta.Repository.List.ListItem(_listDef);


    ListMainForm _listMainForm = ((ListMainForm)_listItem.ListForm.Records[0].FindControlByID("_sys_wf_form"));

    ((ListTextDataItem)_listMainForm.FindControlByID("_sys_wf_title")).Value = "TestWF";

    ((ListTextDataItem)_listMainForm.FindControlByID("_sys_wf_desc")).Value = "Test Workflow";


    ListTableForm _listTableForm = ((ListTableForm)_listItem.ListForm.Records[0].FindControlByID("_sys_wfdef_form"));

    ((ListTextDataItem)_listTableForm.Records[0].FindControlByID("_sys_wfdef_filename")).Value = "1";

    ((ListIntDataItem)_listTableForm.Records[0].FindControlByID("_sys_wfdef_productionid")).Value = "0";

    _listItem.LoggedInUserId = "skeltalist::1AA9AA25-92F8-4635-839B-CB029EB95B2F";


    //1AA9AA25-92F8-4635-839B-CB029EB95B2F is userguid of the user admin in skelta list

     //setting logged-In userid is mandatory  

    _listItem.Save();

 

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