Author Topic: Using COM Application Block to Create List Object with userProperties  (Read 1942 times)

Offline bankleftie

  • Newbie
  • *
  • Posts: 3
  • Karma: 1
Hi. I have a situation where a massive number of list objects frequently need to be imported, and we're doing them one at a time. Each has several Annex Sections, with each section representing the date of a holiday and its KVPs representing treatments to be applied on those days.

From the PSDK C# sample application, I have this code working to add a list object with userProperties (Annex Sections with KVPs):

private void CreateTransaction()
          {
                try
                {
                          CfgTransaction list = new CfgTransaction(confService);
                          list.SetTenantDBID(TENANT_ID);
                          list.Name = "New List":
                          list.Alias = list.Name;
                          list.Type = CfgTransactionType.CFGTRList;
                          KeyValueCollection kvc = new KeyValueCollection;
                          kvc.Add("KEY1","VALUE1");
                          kvc.Add("KEY2","VALUE2");
                          kvc.Add("KEY3","VALUE3");
                          list.UserProperties.Add("ATTRIBUTES", kvc);
                          list.Save();
                          LogRepsonse("List Created");
                }
                catch (Exception e)
                {
                          LogException e)
                }
            } 

This creates the new List Object with one Annex Section called "ATTRIBUTES", containing three KVPs. Additional sections and KVPs can be created by declaring additional KeyValueCollections (e.g., "kvc2") and running the list.UserProperties.Add method at the end of each.

All the key value collections get added at the end with the "list.Save()" method. This is all hard coded and ugly. The next step is to efficiently parameterize this to process hundreds of these at a time, pulling from a config file. Time to get a better understanding of using xml files, I guess.

-Robert
« Last Edit: March 08, 2023, 07:34:28 PM by bankleftie »

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7636
  • Karma: 56330
Re: Using COM Application Block to Create List Object with userProperties
« Reply #1 on: March 09, 2023, 02:19:48 PM »
???  What is the question? Or you are just ranting here hehe