Hi All
As the above says, I am trying to find an alternative to protocol.GetKeysForValue that can be used in an automation script to check a column of a table for a value and retrieve the primary key or display key that matches the value.
Thanks
Ryan
Hi Ryan,
There’s no built-in GetKeysForValue() method available in an automation script, but you can achieve this using a small helper method, for example:
public ICollection<string> GetKeysForValue(Element element, int tablePid, int columnPid, object value)
{
var keys = new List<string>();foreach (var key in element.GetTablePrimaryKeys(tablePid))
{
var cellValue = element.GetParameterByPrimaryKey(columnPid, key);if (Equals(cellValue, value))
{
keys.Add(key);
}
}return keys;
}
Usage:
var element = engine.FindElement("element name");
var keys = GetKeysForValue(element, 1000, 1003, "my value");
Kind regards,
Tom