Eiko Willemsen

Find AF element using a configured targetLocation from an attribute value

Discussion created by Eiko Willemsen on Nov 28, 2011
Latest reply on Nov 29, 2011 by MvanderVeeken
Hello, I'm working on a customization to generate AFElements based on custom templates. As a target Element we try to use an attribute value with value type Element. The Target Element is an attribute of the custom template called Target Location. The Target location can be selected from the AF elements in a small dialog that pops up when clicking the ... button. After saving this location I suspect the entire root of the selected element will be saved so I can use it for creating elements. But when I try to get the Target location in my code, I only get the name of the element which was not the desired result. Now I Have to find my element from a low level element like this: AFElement searchRoot = (AFElement)AFElement.FindObject(AFRootPath); AFElement targetElement = AFElement.FindElements(Element.Database,                                                  searchRoot,                                                  BusinessRuleTempl.TargetLocation.Value.ToString(),                                                  OSIsoft.AF.AFSearchField.Name,                                                  true,                                                  OSIsoft.AF.AFSortField.ID,                                                  OSIsoft.AF.AFSortOrder.Ascending, 1).First(); This way there is a chance I find another element at some other location with the same name. My idea was to find the Element with: AFElement targetElement = (AFElement) AFElement.FindObject(BusinessRuleTempl.TargetLocation.Value.ToString()); Is there any way to retreive the full path from an attribute with an Value type of Element? regards,  Jeroen

Outcomes