Searching AF Elements by Attributes

Discussion created by jbethacr on Jan 10, 2013
Latest reply on Jan 11, 2013 by pcombellick



I'm using FindElement.FindElementByAttribute function, and everything works fine until the value of the attribute has a "\".  The query doesn't return any value in that case.


I tried adding a secon backslash "\\"; but still no records back.




I pasted an extract of the code.  The code below search elements by attributes where attribute "AssetTeam" = "Headlee\Bradford"   


BTW if I use PI systme explorer the search works by using "Headlee\\Bradford" double backslash.


Any ideas why it doesn't work. 


string ObjectValue;


AFElement Lease = findElement(this.AssetTeamTreeView.SelectedNode.Name.ToString()); //"ConMiscellaneous");


AFElementTemplate AFElemTemplate = MCAAFDB.ElementTemplates["Base Business Attribute"];


AFAttributeTemplate AFAttrTemplate = AFElemTemplate.AttributeTemplates["AssetTeam"];


if (Lease.Attributes["AssetName"].GetValue().ToString() == "Headlee/Bradford")


ObjectValue = "Headlee\\Bradford";






ObjectValue = Lease.Attributes["AssetName"].GetValue().ToString();






AFAttributeValueQuery AttributeValue = new AFAttributeValueQuery (AFAttrTemplate, AFSearchOperator.Equal, ObjectValue) ;


AFAttributeValueQuery[] AttributeValues = new AFAttributeValueQuery[1];


AttributeValues[0] = AttributeValue;


AFNamedCollectionList<AFElement> aes2 = AFElement.FindElementsByAttribute(Lease, "*", AttributeValues, true,


AFSortField.Name, AFSortOrder.Ascending, Int32.MaxValue);


BindingSource bs = new BindingSource();


AFCategory myCat = MCAAFDB.ElementCategories["Active"];