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.
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:
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();
}
}
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
var transaction = func.transactionlist_get("test");
KeyValueCollection kvc = new KeyValueCollection();
kvc.Add("KEY", "VALUE");
transaction.UserProperties.Add(kvc);
transaction.Save();
I get Error:{"Validation error : [CFGObjectPackingError] "}
I found my mistake
var transaction = func.transactionlist_get("test");
KeyValueCollection kvc = new KeyValueCollection();
kvc.Add("KEY", "VALUE");
transaction.UserProperties.Add("SECTION", kvc);
transaction.Save();