Genesys CTI User Forum

Genesys CTI User Forum => Genesys-related Development => Topic started by: carpio on October 11, 2017, 03:17:16 PM

Title: sdk update transactionlist
Post by: carpio on October 11, 2017, 03:17:16 PM
Hello,

I know how to get the keys and values from a transactionlist but how can i update a specific value of a key in a section?
Tried the add and set method but without success.
Title: Re: sdk update transactionlist
Post by: PeteHoyle on October 12, 2017, 07:22:14 AM
Hi Carpio,

Try this code:

            [code]
            CfgTransactionQuery query = new CfgTransactionQuery();
            query.Name = "PeteTransactionList";
            CfgTransaction transaction = confService.RetrieveObject<CfgTransaction>(query);
            if (transaction.UserProperties.ContainsKey("MySection"))
            {
                KeyValueCollection section = transaction.UserProperties["MySection"] as KeyValueCollection;
                if (section.ContainsKey("MyName"))
                {
                    section["MyName"] = "NewValue1";
                    transaction.Save();
                }
            }[/code]
Title: Re: sdk update transactionlist
Post by: carpio on October 12, 2017, 08:26:14 AM
Hi Peter,

I was trying it in a kind of complex way but your code looks so easy.
Much appreciated
Title: Re: sdk update transactionlist
Post by: carpio on October 13, 2017, 08:49:00 AM
Hi Pete, can you explain how to add a new section, key and value?
If I try to add the keyvaluepair I get an error

[code]var transaction = func.transactionlist_get("test");
            KeyValueCollection kvc = new KeyValueCollection();
            kvc.Add("KEY", "VALUE");
            transaction.UserProperties.Add(kvc);
            transaction.Save();[/code]
       

I get Error:{"Validation error : [CFGObjectPackingError] "}
Title: Re: sdk update transactionlist
Post by: carpio on October 13, 2017, 10:22:54 AM
I found my mistake

[code] var transaction = func.transactionlist_get("test");
            KeyValueCollection kvc = new KeyValueCollection();
            kvc.Add("KEY", "VALUE");
            transaction.UserProperties.Add("SECTION", kvc);
            transaction.Save();[/code]