Genesys CTI User Forum
Genesys CTI User Forum => Genesys-related Development => Topic started 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.
-
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]
-
Hi Peter,
I was trying it in a kind of complex way but your code looks so easy.
Much appreciated
-
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] "}
-
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]