Genesys CTI User Forum > Genesys-related Development

sdk update transactionlist

(1/1)

carpio:
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.

PeteHoyle:
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]

carpio:
Hi Peter,

I was trying it in a kind of complex way but your code looks so easy.
Much appreciated

carpio:
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] "}

carpio:
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]

Navigation

[0] Message Index

Go to full version